Questions tagged [design-principles]

Design principles are ideas that guide developers toward certain goals in software design.

Software has many different desirable quality aspects -- among them are reliability, security, maintainability, efficiency, and size; and these are all impacted by choices made by the developers. Software design principles tend to focus on the maintainability aspects of quality: is the code loosely coupled, or does it have many dependencies that make it hard to use? Is the code highly cohesive, or is a collection of unrelated information needed to use a module? Is the code readable and understandable? Is the code testable? Is the code usable and reusable? Is the code simple or complex?

Various design principles can be used by developers to advise them in making choices that will yield highly cohesive, loosely coupled, simple, maintainable designs. The SOLID design principles are an example of specific design advice for object oriented projects. The Principles of User Interface Design provide design advice for creating user interfaces.

309 questions
2
votes
1 answer

Interface Segregation Principle in jQuery

Anyone able to give a good illustration of how this works in jQuery? Specifically with regards to the answer from here. It sounds the same as Single Responsibility Principle (SRP) for OOP? How is it different?
bcm
  • 5,470
  • 10
  • 59
  • 92
2
votes
2 answers

Using inheritance with a parent class which contains empty strings for variables that are only applicable in child classes

I am trying to model geographic locations in OOP. Location types are as follows:continent, country, state, county or more specific (e.g city, town, village, all modeled as a single type). Continents have continent code, counties have continent code…
2
votes
3 answers

What is naming convention for DTOs in a webservice

I'm designing a restful web service and I was wondering what should I name my DTOs. Can I use suffixes like Request and Response for them? for example for addUser service, there will be 2 DTOs named: AddUserRequest and AddUserResponse.
2
votes
1 answer

Structural design patterns: (Private class data) Is there a difference between these two examples

The following is an example of this pattern from sourcemaking.com: https://sourcemaking.com/design_patterns/private_class_data There are two examples, the crossed out main class and the main class that contains the data class. My question is simply…
2
votes
1 answer

Acyclic Dependency Principle - How could component dependency cycles be reason for "morning-after syndrome"?

I am reading "Agile Principles, Patterns, and Practices in C#" by Robert Martin. And currently I am reading about Acyclic Dependency Principle(ADP). And I cant udnerstand one part in that section. Let me explain the part in a short. Firstly author…
2
votes
2 answers

Wrapping function arguments?

Let's suppose that I have this function: void foo (struct1 &v1, struct2 &v2, ..., structn &vn){ //do something with a subset some of the arguments... foo1(v1, v2, ..., vn); } void foo1 (struct1 &v1, struct2 &v2, ..., structn &vn){ //do…
justHelloWorld
  • 6,478
  • 8
  • 58
  • 138
2
votes
1 answer

Single Responsibility(SRP) vs Tell Don't Ask(TDA)?

I understand that many design principles conflict with each other in some cases . So, we have to weigh them and see which one is more beneficial. Till now I was aware of SRP principle and did my lot of designs solely based on that but internally I…
emilly
  • 10,060
  • 33
  • 97
  • 172
2
votes
1 answer

Should I add new methods to a class instead of using Single Responsibility Principle

We had a seminar where I presented Single Responsibility Principle to my team so that we use it in our projects. I used the following popular example: class Employee: save() calculate_salary() generate_report() And I asked the team to…
2
votes
1 answer

Composite design pattern: how to pass results from one component into another?

I have the following code: interface IService { void Execute(); } class ServiceA : IService { public void Execute() { ... } } class ServiceB : IService { public void Execute() { ... } } class ServiceComposite : IService { …
Signum
  • 845
  • 1
  • 10
  • 33
2
votes
2 answers

Should concrete implementation provide any public API not present in the interface it implements?

"Code to interfaces" is considered good practice. Such code is easy to unit test and enables loose coupling. Users only know the interfaces and the onus of wiring concrete objects is upon the top-most level (this can be done in some init code or…
nits.kk
  • 5,204
  • 4
  • 33
  • 55
2
votes
1 answer

Max number of Activities!

Is there any design guideline on the number of Activities an application could have? If there is a limit, what would be the ideal number of Activities that can be bundled in an Android application.
2
votes
1 answer

How to avoid redundant business logic (DB fetching) when creating DTO?

I'm developing N-Tier application in C#. Server side consists of this layers: Data access layer (EF Code First Entities and DbContext) Business layer (contains all business logic and objects) WCF Service layer (per-call instanstiated services that…
2
votes
2 answers

If the execution of the bulk of a function is conditional on the input, which of these is a better way to implement?

I'm wondering which of these is better and why. I often encounter situations in my daily work where I'm like "This algorithm works so long as the input isn't empty" or something like that. I usually just return early because, for some reason, the…
user5526721
2
votes
1 answer

What is the difference between Layout and Design?

I can't understand what is Design and what is Layout in the web-design. I'm confused about layout and design.
Shadat501
  • 149
  • 1
  • 2
  • 8
2
votes
1 answer

Correct implementation of the Filter (Criteria) Design Pattern

The design pattern is explained here: http://www.tutorialspoint.com/design_pattern/filter_pattern.htm I'm working on a software very similar to Adobe Lightroom or ACDSee but with different purposes. The user (photographer) is able to import…
Stephen H. Anderson
  • 978
  • 4
  • 18
  • 45