A query on software design/architectureDoes functional programming replace GoF design patterns?Software Design vs. Software ArchitectureExamples of GoF Design Patterns in Java's core librariesMaking this class comply with the Dependency Inversion principleUser interface depending on business logic layer breaks dependency inversion principle?What is the difference between DI principle and “Program to interface, not to implementation”?Finding the High-Level and Low-Level modules in dependencies for applying Dependency Inversion PrincipeDependency Inversion Principle (SOLID) vs Encapsulation (Pillars of OOP)Dependency Inversion Principle's second statement elaborationConfusion between Inversion of Control and Hollywood Principle
How could it be that the capo isn't changing the pitch?
When is it legal to castle moving the rook first?
'Hard work never hurt anyone' Why not 'hurts'?
Travel to USA with a stuffed puppet
co-son-in-law or co-brother
Deleting millions of records on SQL Server 14.0
Does secure hashing imply secure symmetric encryption?
How do I name the individual parts of the lumbricals muscle of the foot in latin?
Select single features in selection
What's the difference between a share and a stock?
What is the significance of 104%?
Has Rey's new lightsaber been seen before in canon or legends?
How to generate all 3×3 matrices with a,a,a,a,b,b,b,c,c?
To which airspace does the border of two adjacent airspaces belong to?
Can there be plants on the dark side of a tidally locked world?
Why don't they build airplanes from 3D printer plastic?
Is torque as fundamental a concept as force?
How does Harry wear the invisibility cloak?
Case Studies and Real Problems for Teaching Optimization and Modelling
Planet that’s 90% water or more?
What drugs were used in England during the High Middle Ages?
A rather curious equality: is this true?
Punishment in pacifist society
Japanese equivalent for "get to do something"?
A query on software design/architecture
Does functional programming replace GoF design patterns?Software Design vs. Software ArchitectureExamples of GoF Design Patterns in Java's core librariesMaking this class comply with the Dependency Inversion principleUser interface depending on business logic layer breaks dependency inversion principle?What is the difference between DI principle and “Program to interface, not to implementation”?Finding the High-Level and Low-Level modules in dependencies for applying Dependency Inversion PrincipeDependency Inversion Principle (SOLID) vs Encapsulation (Pillars of OOP)Dependency Inversion Principle's second statement elaborationConfusion between Inversion of Control and Hollywood Principle
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
In book 'Patterns of Enterprise Application Architecture', following is stated:
When thinking of a system in terms of layers, you imagine the principal subsystems
in the software arranged in some form of layer cake, where each layer
rests on a lower layer. In this scheme the higher layer uses various services
defined by the lower layer, but the lower layer is unaware of the higher layer.
On other hand, in book 'Agile Principles, Patterns, and Practices', following is stated on Dependency-Inversion Principle:
High-level modules should not depend on low-level modules. Both should depend
on abstractions.
This sort of confuses me. Am I mixing two different things here?
oop design-patterns architecture
add a comment |
In book 'Patterns of Enterprise Application Architecture', following is stated:
When thinking of a system in terms of layers, you imagine the principal subsystems
in the software arranged in some form of layer cake, where each layer
rests on a lower layer. In this scheme the higher layer uses various services
defined by the lower layer, but the lower layer is unaware of the higher layer.
On other hand, in book 'Agile Principles, Patterns, and Practices', following is stated on Dependency-Inversion Principle:
High-level modules should not depend on low-level modules. Both should depend
on abstractions.
This sort of confuses me. Am I mixing two different things here?
oop design-patterns architecture
add a comment |
In book 'Patterns of Enterprise Application Architecture', following is stated:
When thinking of a system in terms of layers, you imagine the principal subsystems
in the software arranged in some form of layer cake, where each layer
rests on a lower layer. In this scheme the higher layer uses various services
defined by the lower layer, but the lower layer is unaware of the higher layer.
On other hand, in book 'Agile Principles, Patterns, and Practices', following is stated on Dependency-Inversion Principle:
High-level modules should not depend on low-level modules. Both should depend
on abstractions.
This sort of confuses me. Am I mixing two different things here?
oop design-patterns architecture
In book 'Patterns of Enterprise Application Architecture', following is stated:
When thinking of a system in terms of layers, you imagine the principal subsystems
in the software arranged in some form of layer cake, where each layer
rests on a lower layer. In this scheme the higher layer uses various services
defined by the lower layer, but the lower layer is unaware of the higher layer.
On other hand, in book 'Agile Principles, Patterns, and Practices', following is stated on Dependency-Inversion Principle:
High-level modules should not depend on low-level modules. Both should depend
on abstractions.
This sort of confuses me. Am I mixing two different things here?
oop design-patterns architecture
oop design-patterns architecture
edited Mar 28 at 6:35
Svetlin Zarev
7,1703 gold badges30 silver badges60 bronze badges
7,1703 gold badges30 silver badges60 bronze badges
asked Mar 28 at 2:49
MandroidMandroid
1,0761 gold badge14 silver badges31 bronze badges
1,0761 gold badge14 silver badges31 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
I suppose that it could speak to some the same principles, but at different levels of granularity. I would still view Dependency Inversion as something that stands on its own, however.
In the first instance, consider this example - in a simple layered architecture, you might have a presentation layer built in JavaScript, a business logic layer built in Java, and a data layer in SQL Server. These layers could be developed by different teams of people. The presentation layer knows how to make API calls to the business logic layer, but not the other way around. The business logic layer knows how to read/write to and from the database layer, but not the other way around. The distinction here happens at a high-level - you might even call it conceptual.
In the second instance, you want to prevent scenarios where supposedly generic code depends on specific implementations - and at this point, I see it as a relatively low-level concern that falls within the scope of a particular application (i.e. in code, not conceptually as in the previous example). If you have code that writes to a database, but you want to support different implementations - e.g. MySQL and SQL Server, where each of those might have some specific intricacies, don't make the calling code explicitly depend on either of those - abstract away the complexity through an interface. This is what the Dependency Inversion Principle addresses (see below).
public class UserService
public UserRepository repository;
public void setUserRepository(UserRepository repository)
this.repository = repository; //Is this a MySqlRepository or a SqlServerRepository? We don't care - the dependency is managed outside and we can change it without changing this class.
public void persistUser()
this.repository.persist(user); //We just care about the abstraction - the interface.
add a comment |
Am I mixing two different things here?
Yes.
The first case is about dependencies at run-time while the second case is about dependencies at compile-time.
For example, at run-time, business layer can call the functions/methods implemented in database layer. But at compile-time, business layer code does not mention any code in database layer. This is usually achieved with Polymorphism.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55389467%2fa-query-on-software-design-architecture%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I suppose that it could speak to some the same principles, but at different levels of granularity. I would still view Dependency Inversion as something that stands on its own, however.
In the first instance, consider this example - in a simple layered architecture, you might have a presentation layer built in JavaScript, a business logic layer built in Java, and a data layer in SQL Server. These layers could be developed by different teams of people. The presentation layer knows how to make API calls to the business logic layer, but not the other way around. The business logic layer knows how to read/write to and from the database layer, but not the other way around. The distinction here happens at a high-level - you might even call it conceptual.
In the second instance, you want to prevent scenarios where supposedly generic code depends on specific implementations - and at this point, I see it as a relatively low-level concern that falls within the scope of a particular application (i.e. in code, not conceptually as in the previous example). If you have code that writes to a database, but you want to support different implementations - e.g. MySQL and SQL Server, where each of those might have some specific intricacies, don't make the calling code explicitly depend on either of those - abstract away the complexity through an interface. This is what the Dependency Inversion Principle addresses (see below).
public class UserService
public UserRepository repository;
public void setUserRepository(UserRepository repository)
this.repository = repository; //Is this a MySqlRepository or a SqlServerRepository? We don't care - the dependency is managed outside and we can change it without changing this class.
public void persistUser()
this.repository.persist(user); //We just care about the abstraction - the interface.
add a comment |
I suppose that it could speak to some the same principles, but at different levels of granularity. I would still view Dependency Inversion as something that stands on its own, however.
In the first instance, consider this example - in a simple layered architecture, you might have a presentation layer built in JavaScript, a business logic layer built in Java, and a data layer in SQL Server. These layers could be developed by different teams of people. The presentation layer knows how to make API calls to the business logic layer, but not the other way around. The business logic layer knows how to read/write to and from the database layer, but not the other way around. The distinction here happens at a high-level - you might even call it conceptual.
In the second instance, you want to prevent scenarios where supposedly generic code depends on specific implementations - and at this point, I see it as a relatively low-level concern that falls within the scope of a particular application (i.e. in code, not conceptually as in the previous example). If you have code that writes to a database, but you want to support different implementations - e.g. MySQL and SQL Server, where each of those might have some specific intricacies, don't make the calling code explicitly depend on either of those - abstract away the complexity through an interface. This is what the Dependency Inversion Principle addresses (see below).
public class UserService
public UserRepository repository;
public void setUserRepository(UserRepository repository)
this.repository = repository; //Is this a MySqlRepository or a SqlServerRepository? We don't care - the dependency is managed outside and we can change it without changing this class.
public void persistUser()
this.repository.persist(user); //We just care about the abstraction - the interface.
add a comment |
I suppose that it could speak to some the same principles, but at different levels of granularity. I would still view Dependency Inversion as something that stands on its own, however.
In the first instance, consider this example - in a simple layered architecture, you might have a presentation layer built in JavaScript, a business logic layer built in Java, and a data layer in SQL Server. These layers could be developed by different teams of people. The presentation layer knows how to make API calls to the business logic layer, but not the other way around. The business logic layer knows how to read/write to and from the database layer, but not the other way around. The distinction here happens at a high-level - you might even call it conceptual.
In the second instance, you want to prevent scenarios where supposedly generic code depends on specific implementations - and at this point, I see it as a relatively low-level concern that falls within the scope of a particular application (i.e. in code, not conceptually as in the previous example). If you have code that writes to a database, but you want to support different implementations - e.g. MySQL and SQL Server, where each of those might have some specific intricacies, don't make the calling code explicitly depend on either of those - abstract away the complexity through an interface. This is what the Dependency Inversion Principle addresses (see below).
public class UserService
public UserRepository repository;
public void setUserRepository(UserRepository repository)
this.repository = repository; //Is this a MySqlRepository or a SqlServerRepository? We don't care - the dependency is managed outside and we can change it without changing this class.
public void persistUser()
this.repository.persist(user); //We just care about the abstraction - the interface.
I suppose that it could speak to some the same principles, but at different levels of granularity. I would still view Dependency Inversion as something that stands on its own, however.
In the first instance, consider this example - in a simple layered architecture, you might have a presentation layer built in JavaScript, a business logic layer built in Java, and a data layer in SQL Server. These layers could be developed by different teams of people. The presentation layer knows how to make API calls to the business logic layer, but not the other way around. The business logic layer knows how to read/write to and from the database layer, but not the other way around. The distinction here happens at a high-level - you might even call it conceptual.
In the second instance, you want to prevent scenarios where supposedly generic code depends on specific implementations - and at this point, I see it as a relatively low-level concern that falls within the scope of a particular application (i.e. in code, not conceptually as in the previous example). If you have code that writes to a database, but you want to support different implementations - e.g. MySQL and SQL Server, where each of those might have some specific intricacies, don't make the calling code explicitly depend on either of those - abstract away the complexity through an interface. This is what the Dependency Inversion Principle addresses (see below).
public class UserService
public UserRepository repository;
public void setUserRepository(UserRepository repository)
this.repository = repository; //Is this a MySqlRepository or a SqlServerRepository? We don't care - the dependency is managed outside and we can change it without changing this class.
public void persistUser()
this.repository.persist(user); //We just care about the abstraction - the interface.
answered Mar 28 at 6:29
Riaan NelRiaan Nel
1,4403 silver badges13 bronze badges
1,4403 silver badges13 bronze badges
add a comment |
add a comment |
Am I mixing two different things here?
Yes.
The first case is about dependencies at run-time while the second case is about dependencies at compile-time.
For example, at run-time, business layer can call the functions/methods implemented in database layer. But at compile-time, business layer code does not mention any code in database layer. This is usually achieved with Polymorphism.
add a comment |
Am I mixing two different things here?
Yes.
The first case is about dependencies at run-time while the second case is about dependencies at compile-time.
For example, at run-time, business layer can call the functions/methods implemented in database layer. But at compile-time, business layer code does not mention any code in database layer. This is usually achieved with Polymorphism.
add a comment |
Am I mixing two different things here?
Yes.
The first case is about dependencies at run-time while the second case is about dependencies at compile-time.
For example, at run-time, business layer can call the functions/methods implemented in database layer. But at compile-time, business layer code does not mention any code in database layer. This is usually achieved with Polymorphism.
Am I mixing two different things here?
Yes.
The first case is about dependencies at run-time while the second case is about dependencies at compile-time.
For example, at run-time, business layer can call the functions/methods implemented in database layer. But at compile-time, business layer code does not mention any code in database layer. This is usually achieved with Polymorphism.
answered Mar 28 at 8:32
Nghia BuiNghia Bui
2,5769 silver badges18 bronze badges
2,5769 silver badges18 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55389467%2fa-query-on-software-design-architecture%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown