Вопрос

Engineering is typically the art of knowing what solution fits best to the problem. If I were asked such as Should I use singleton classes?, Should all database have views and triggers?, What is the greatest PHP framework?, Is C++ or Go better?, or Is RSA or AES more secure? I will most certainly answer "It depeneds..."

But one question stands out, "Should I use modular design?" - "Absolutely"

I have not once doubted modular design in my experience. Software that I make must be assembled, put together, and interchangeable like Lego bricks (after you define what a brick is of course). No matter what language, no matter what machine, no matter what purpose, ect. So I have yet to say "it depends" when ask if modular design should be used.

Nearly every other aspect of software engineering has a take-give index it can be put on. Modular design (so far) only ever gives and gives. This frightens me and I constantly seek out why anyone would not use modular design. I mean if you program in such a way where all the code is glued together and contains variable length functionally and limited expandability, and no means of error severability, does that automatically mean you're a bad programmer? Is there any reason to code in that fashion besides laziness? Are their any other ways to design a project in? Or is modular designing the above all most 100% undisputed right way of doing things (just like breathing)?

Это было полезно?

Решение

Modular design requires (a non insignificant cognitive) effort as a design heuristic, but its benefits come back in

  • managing complexity,
  • simplifying long-term maintenance,
  • facilitating reuse,
  • etc.

So, a project that doesn't care about any of those things would be one where modular design would be a waste. It's similar to Thomas Kilian's answer mentioning very small systems.

For an analogy, think about IKEA furniture and all the modular design effort that go into it. Then, ask yourself if you just needed a table to put food out for guests for a one-night celebration, you'd hack something out of whatever you had at your disposal to solve the problem (kids do this quite well!). Designing a new IKEA-like table (with modular parts) for this purpose would be overkill for your one-night party.

I like Neal Ford's spectrum of design. Modular design (the way I see this) would not even exist at the "cowboy hacking" extreme.

http://www.slideshare.net/ThoughtWorks/neal-ford-emergent-design-and-evolutionary-architecture

Другие советы

What is NON modular design? For me it would be a monolithic design. Those have advantages in very small systems. This is where any kind of resource is limited. That might be memory, CPU or even the time a coder can spend to create it. A monolithic design can be grasped in one single piece (or more specifically it NEEDS to be). In that way you get the whole picture. But again, you NEED to get the whole picture. So as long as the system is small, this will be feasible. Starting from a certain size you definitely want modular design. Rule 1 to eat an elephant: eat it in slices.

Лицензировано под: CC-BY-SA с атрибуция
scroll top