Suggested Answers about Technical Design for Software Developers
For most of the questions in this list there are no right and wrong answers!
1. What do low coupling and high cohesion mean? What does the principle of encapsulation mean?
Coupling refers to how strongly or loosely components in a system are tied together. You want that to be low. Cohesion refers to how well the individual parts of a unit of code fit together for a single purpose. Encapsulation is about containing implementation of code so that outsiders don’t need to know how it’s works on the inside. By doing so you can reduce negative effects of coupling.
Encapsulation is one of the fundamentals of OOP (object-oriented programming). It refers to the bundling of data with the methods that operate on that data. Encapsulation is used to hide the values or state of a structured data object inside a class, preventing unauthorized parties’ direct access to them. Publicly accessible methods are generally provided in the class (so-called getters and setters) to access the values, and other client classes call these methods to retrieve and modify the values within the object.
2. How do you manage conflicts in a web application when different people are editing the same data?
Set a flag when someone starts editing data unit A. If someone else loads it, let them know it’s being edited and that it’s currently in read only mode. If the race was too fast, you can also have a check on the commit side to let them know their changes conflict with another user, present them the data, and then let them figure out how to merge the changes. This has rarely been a problem in my experience, but it could be, and that’s how I’d deal with it if the requirement came up. (If the changes don’t conflict, you could simply keep the user unaware as well.)
3. Do you know about design patterns? Which design patterns have you used, and in what situations?
Most of the ones I’m familiar with aren’t of much daily use to me, as I tend to work in dynamic languages, where the sorts of flaws that precipitate the patterns (as implemented in the book) just aren’t factors as often as in other languages.
I suppose most frequently I’ve used the Strategy pattern. (Perhaps the fact that I’ve focused so much on one in particular is a weakness in my coding style?) The situations are when an interface should remain the same while the implementation should differ somewhat. I don’t have a concrete example on the top of my head.
If I were to start working in Java again, or building larger applications in .NET (I currently build very small apps in that space as part of my job), I’d re-read the book. I might even scan the inner cover daily just as a refresher.
I wouldn’t say I’m strong on design patterns, but I’ve got reference information and know where to look should I need to, along with the facilities to become strong should my situation call for it.
read more: The Wikipedia article on Strategy pattern
4. Do you know what a stateless business layer is? Where do long-running transactions fit into that picture?
I hadn’t heard it as a single term until now, but knowing the individual terms lets me say that objects in the business layer (or domain model) are transient — or that their state is not preserved in memory between subsequent requests for the same object.
This may note bode well for long running transactions, as state presumably must be set up each time an object is loaded, along with any process that might be required for tear-down.
5. What kinds of diagrams have you used in designing parts of an architecture, or a technical design?
UML has always been enough. Most likely the bastardized part where we just do a little design on paper or a whiteboard to gain a better understanding of the intended design through some sketch-work.
I’ve never been a part of a team that practices BDUF, nor have I felt the need for it in any personal projects, so I’m light on recommendations for reading.
read more: The Wikipedia article on UML
6. Can you name the different tiers and responsibilities in an N-tier architecture?
N-tier architecture is also called multi-tier architecture because the software is engineered to have the processing, data management, and presentation functions physically and logically separated. That means that these different functions are hosted on several machines or clusters, ensuring that services are provided without resources being shared and, as such, these services are delivered at top capacity. The “N” in the name n-tier architecture refers to any number from 1.
Not only does your software gain from being able to get services at the best possible rate, but it’s also easier to manage. This is because when you work on one section, the changes you make will not affect the other functions. And if there is a problem, you can easily pinpoint where it originates.
read more: What is N-Tier Architecture?
7. Can you name different measures to guarantee correctness and robustness of data in an architecture?
It seems to me this is a product of many things, and I don’t know where to start. For instance, we could say that unit tests and integration tests can go part of the way there. We could talk about validating user input, and that it matches some definition of «looking correct.» We could have checks coded and in place between the various systems that make up the architecture. Constraints on the database. I could go on if I were giving myself more time to think about it.
Because of the open-endedness in this question, there are any number of references. I’d dive into automated testing in its various forms, which when applied to the situation, should get you most of the way there.
8. Can you name any differences between object-oriented design and component-based design?
To be honest, this is the first I’ve heard of component-based design, so no, I can’t name the differences. My thoughts would go towards having objects to design around (as in C++) vs. not having objects to design around (as in C).
Object Oriented Programming provides the ability to organise our programs or applications into objects. Objects represent real life things and also computationally important things. They can represent a product, a cart that holds products or the algorithm to find relevant products for a specific user.
read more: Comparing OOP and Component Based Design
9. How would you model user authorization, user profiles and permissions in a database?
I wouldn’t typically model the authorization piece in the DB. If I read you correctly, I’m guessing you mean the storage of authorization information in the database, as opposed to the act of authorizing. Under that assumption, I’ve modeled this situation in just about every way I can imagine. A couple of scenarios:
a. Under a denormalized scenario, I’d keep a table of permissions and a table of users (which includes authorization information, profile information, and a list of permissions from the users table). This isn’t ideal if permissions ever change, and especially not if you’re returning a ton of users for the purpose of authorization while the profile information is especially large. In that case you’re transferring way more data than you need, and it could result in performance problems. (The extra data transfer may only be a problem with ORM tools, as you could always hand-write the queries to return only what you need. On the other hand, storing of redundant data is a problem if storage space itself is an issue.)
b. Under a completely normalized scenario, we’d have a table of permissions, a table relating users to permissions, and a table for users. For the sake of cohesion (and potentially optimizing data transfer) we might separate the users table into one for authentication and another for profile, while keeping the relationship with permissions based on user_auth.
c. Some variation in between the two extremes.
read more: Database normalization
10. How would you model the animal kingdom (with species and their behavior) as a class system?
This one might deserve a blog post all on its own. It depends: If I’m working in a language with multiple inheritance, I’d use a combination of class hierarchy that follows the animal kingdom along with mixins (which are also inheritance, but with less of a hierarchical attitude) for behavior shared between and among the hierarchy levels. Without multiple inheritance, I’d have to resort to interfaces where available, and composition for actual code reuse where it made sense.
The short answer though, is that I probably wouldn’t implement it as a class system. If I really was working with taxonomy and biological classification, I don’t think I’d model the real world with objects. I’d need to look into the subject quite a bit further to tell you how I would do it, but suffice to say I don’t think it’d be using objects to match it one-for-one, or even something resembling one-to-one.
*partly accepted from the article