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
1
vote
4 answers

OOP - Do I over complicate things?

I was looking at some of my projects and comparing them to things I've seen on github and I feel like I over-think things. I like OOP but I feel like I make too many files, too many classes. For example, on a small project I had of a game of…
Van-Sama
  • 1,154
  • 4
  • 14
  • 21
1
vote
2 answers

Applying Single Responsibility principle on class?

Single Responsibility Principle(SRP) :- Every class should have single responsibility. Basically, there should be a single reason to change. I am not sure what exactly the last statement means. My interpretation is that to design the classes in a…
emilly
  • 10,060
  • 33
  • 97
  • 172
1
vote
1 answer

Abstraction should be packaged with High level modules?

Wiki says In a direct application of dependency inversion, the abstracts are owned by the upper/policy layers. This architecture groups the higher/policy components and the abstractions that define lower services together in the same package.…
emilly
  • 10,060
  • 33
  • 97
  • 172
1
vote
2 answers

Who should be responsible for calling a method?

If I have complex a task to solve I sometimes end up in a situation where I have one method that controls the execution. Because of null checks, if statements, calling methods that map between types and so on, this method can become really long and…
1
vote
1 answer

Sharing a domain model between different software modules.

Consider the following situation. Three apps A,B and C must cooperate together: A is an external, third party app while B and C are in-house apps (so we have control over B and C, not over A). B replies to requests made by A, using both logics…
1
vote
1 answer

How to gracefully integrate unit testing where none is present?

I have been tasked with developing a document for internal testing standards and procedures in our company. I've been doing plenty of research and found some good articles, but I always like to reach out to the community for input on here. That…
1
vote
1 answer

How do I make model in MVC for iOS app dynamic based on changes in REST-ful API?

We're building an iOS app using Realm as our model / database but we want to design the client so it can easily accommodate changes in the REST-ful API that may occur in the future. Lets say we're developing an app for sports competition…
1
vote
1 answer

Is an implicit property type same with an explicit property type?

The following Code A is from Kotlin-for-Android-Developers. The Code B is written by me. Do these two different blocks of code function the same way? Code A class DetailActivity : AppCompatActivity(), ToolbarManager { override val toolbar by…
HelloCW
  • 843
  • 22
  • 125
  • 310
1
vote
5 answers

Why they integrate stream API to collection framework in java 8

When learning about design patterns I heard that delegation is better than inheritance in most cases. Thus I wonder why the java8 team made the decision to integrate Stream API into the existing Collections framework instead of using delegation…
Tu Tran
  • 101
  • 9
1
vote
3 answers

Liskov substitution design principle adaptation

Let's say I have an abstract class bird, and one of its functions is fly(int height). I have numerous different bird classes, each with it's own different implementation of fly, and the function is used extensively across the application. One day my…
1
vote
1 answer

Use special 'propose' object's instead of arrays

its gonna be a fully theoretical thread. Let's talk about change arrays to specially object's, to compare and work on it. For example we have a EntityClass, EntityInterface, SomeRepository, SomeManager, SomeCommand. Entities is a clear object,…
1
vote
0 answers

Should objects expose high level, 'processed' information or low level, 'raw data'?

Is there a design principle relating to this? Here's the two approaches I'm currently aware of: Approach 1: Expose 'higher level', 'processed' information which consumers can readily use. abstract class Vehicle { bool IsMoving(); } The downside…
grae22
  • 104
  • 11
1
vote
0 answers

java - Do every Class violate Single Responsibility Principle

I have just read about Singleton Pattern's drawbacks. One of the drawbacks is Singleton Pattern violates Single Responsibility Principle, because of policing the instances of itself and providing configuration information. And I wonder, do every…
Tran Thien Chien
  • 643
  • 2
  • 6
  • 17
1
vote
2 answers

How to subscribe to events raised in multiple instances of a class?

I'm working on a small Unity project with C#. I have a class UnitManager that contains a list of instances of class Unit. I want to raise an event, whenever a property (e.g. Health) changes within an instance of Unit. I am also using the UnitManager…
milosa
  • 833
  • 1
  • 8
  • 18
1
vote
1 answer

What's the best practice when an AngularJS directive has a lot of bindings in its isolated scope?

Suppose each card-item directive needs to know a lot of outside contexts and acts accordingly. We could make a service to monitor the outside world, and inject the service into card-item directive, like: scope: { item: '=', service:…