Don’t marry the framework!

Don’t marry the framework!

In effect, the author is asking you to marry the framework—to make a huge, long-term commitment to that framework. And yet, under no circumstances will the author make a corresponding commitment to you. It’s a one-directional marriage. You take on all the risk and burden; the framework author takes on nothing.

The Risks

Here are just a few for you to consider.

  • The architecture of the framework is often not very clean. Frameworks tend to violate the Dependency Rule. They ask you to inherit their code into your business objects—your Entities! They want their framework coupled into that innermost circle. Once in, that framework isn’t coming back out. The wedding ring is on your finger; it will stay there.
  • The framework may help you with some early features of your application. However, as your product matures, it may outgrow the facilities of the framework. If you’ve put on that wedding ring, you’ll find the framework fighting you more and more as time passes.

  • The framework may evolve in a direction that you don’t find helpful. You may be stuck upgrading to new versions that don’t help you. You may even find old features, which you made use of, disappearing or changing in ways that are difficult for you to keep up with.
  • A new and better framework may come along that you wish you could switch to.

The Solution

You can use the framework—just don’t couple to it. Keep it at arm’s length. Treat the framework as a detail in one of the outer circles of the architecture. Don’t let it into the inner circles.

If the framework wants you to derive your business objects from its base classes, say no! Derive proxies instead, and keep those proxies in components that are plugins to your business rules.

Don’t let frameworks into your core code. Instead, integrate them into components that plug into your core code, following the Dependency Rule.

For example, maybe you like Spring. Spring is a good dependency injection framework. Maybe you use Spring to auto-wire your dependencies. That’s fine, but you should not sprinkle @autowired annotations all throughout your business objects. Your business objects should not know about Spring.

Instead, you can use Spring to inject dependencies into your Main component. It’s OK for Main to know about Spring since Main is the dirtiest, lowest-level component in the architecture.

I Now Pronounce You ...

There are some frameworks that you simply must marry. If you are using C++, for example, you will likely have to marry STL—it’s hard to avoid. If you are using Java, you will almost certainly have to marry the standard library.

That’s normal—but it should still be a decision. You must understand that when you marry a framework to your application, you will be stuck with that framework for the rest of the life cycle of that application. For better or for worse, in sickness and in health, for richer, for poorer, forsaking all others, you will be using that framework. This is not a commitment to be entered into lightly.

Conclusion

When faced with a framework, try not to marry it right away. See if there aren’t ways to date it for a while before you take the plunge. Keep the framework behind an architectural boundary if at all possible, for as long as possible. Perhaps you can find a way to get the milk without buying the cow.

要查看或添加评论,请登录

Thomas Said的更多文章

  • Software Architecture: Component Cohesion Principles

    Software Architecture: Component Cohesion Principles

    We will discuss the principles of component cohesion: REP: The Reuse/Release Equivalence Principle CCP: The Common…

    1 条评论
  • Becoming better with continuous learning

    Becoming better with continuous learning

    Continually absorb new knowledge and enhance your skill set to make better decisions in your work. Continuous learning…

  • Data Stores: Structured data VS Unstructured data

    Data Stores: Structured data VS Unstructured data

    Structured data stores Structured data stores have been around for decades and are the most familiar technology choice…

  • The Power of Using Generative AI in Automation

    The Power of Using Generative AI in Automation

    Artificial Intelligence (AI) has become a driving force behind automation, revolutionizing the way businesses operate…

  • The Power of Microservices: Principles and Architecture

    The Power of Microservices: Principles and Architecture

    In today's fast-paced and ever-evolving digital landscape, software development has undergone a transformative shift…

    2 条评论
  • Making Postgres 30% Faster in Production

    Making Postgres 30% Faster in Production

    PgCat Prepared Statements PgCat supports prepared statements in session and transaction mode. Our initial benchmarks…

  • Designing Principles for operational excellence

    Designing Principles for operational excellence

    Operational excellence is running your application with minimal interruption to gain maximum business value. It is…

  • How to Plan to Migrate to the cloud?!

    How to Plan to Migrate to the cloud?!

    Creating a cloud migration strategy As we mentioned in the previous section, there could be various reasons for cloud…

  • How to build MVP like an architect?

    How to build MVP like an architect?

    For a successful solution, always put the customer first, while taking care of architectural constraints. Think…

  • Attributes of the Solution Architecture

    Attributes of the Solution Architecture

    The solution architecture needs to consider multiple attributes and design applications. Solution design may have a…

社区洞察

其他会员也浏览了