How to start with class design for an enterprise application?

How can I start with class design before starting developing a large application (both WinForm and WebApp). What are the initial “cautious” things that I should check before designing class structures?

How to determine the use of interfaces, abstract classes, delegates, events, etc. in application design?

+4
source share
3 answers

A thorough answer to this question will require a book, not a StackOverflow message! In fact, there are already many books about this, such as Martin Fowler Enterprise Application Architecture Templates . Here are some general pointers:

  • Make sure you understand the part of the problem domain that you are working on. Have you spoken to your customers to launch them first? Does your domain model fit the way they think of the world?

  • Statistically speaking, your application is unlikely to be special. This means that if someone claims that they need a specific architecture or implementation template to work (for example, an enterprise service bus, message queues, etc.), you should look at it skeptically. Think about the best other approach.

  • To isolate unconnected parts of an application from each other structurally as well as logically. Do not just relax and do not share your activities; make them completely separate projects that need to be built separately.

  • Code for the interface, not for implementation. If several classes all do something similar, create an interface. Do not use abstract base classes as pseudo-interfaces. Depends on the interface and passes it, not individual implementing classes.

  • Understand a wide area of ​​application. What business purpose does this serve? How does this help people achieve goals or increase productivity? What are you building up to this goal? Make sure you are not building for the sake of construction.

  • Be careful when someone tells you that this is a "corporate application." This is a busy term with too many connotations for too many different people. Ensure clarity regarding cross-cutting issues such as security, authorization, authentication, service guarantees, etc.

  • Enterprise applications are prone to bloat. Don't be afraid to say no to new features and mercilessly reorganize with good unit tests to make sure you get the most impact on your dollar.

  • Finally, everything is in moderation. Taking any of the above (or anything at all) to the extreme is a bad idea. The only thing you need to do as a last resort is moderation itself! :)

+9
source

To give a short answer to a big question, do not start with class design first. Start by developing components, layers, and make some technological decisions, such as "Do I need a database, and if so, which one." This suggests that you have already done part of the analysis of your problem domain, found some important use cases, etc.

When you're ready with this, it might be a good idea to code an “end-to-end” application to test your architecture. This means a small application that affects most of your layers when dealing with a very small use case. It should be small enough to be easy to rewrite / fix / throw away if you think parts of your architecture are corrupted. This is also a good technique for first grabbing your class.

+2
source

I see two main types of project activities.

There is decomposition in the primary parts of the system. So, you already have an idea of ​​separating parts of the presentation from the rest of your system. You probably also have business logic and persistence. The first important question is how much Business Logic you really have. Some systems are a little more than thin skin in front of a simple database, hardly any true business logic. Others have very important pieces of business logic that are somewhat independent.

If you have basic semi-independent parts, they can communicate better through events and message queues. Therefore, indicate whether you have fragments that need such an unleashed relationship, and this leads to the identification of events and useful data of these events. Here, where Fowler refers in another answer, becomes relevant.

Then check the details of the business logic. Interfaces and abstract classes, etc. - these are methods of structuring the implementation of complexity. Separate your code so that details are hidden and flexibility is included. I see this as an OO design exercise, there are many books about this, for example head first .

+1
source

Source: https://habr.com/ru/post/1313505/


All Articles