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
0
votes
3 answers

Interface per base class design

consider i have a Customer Class and it got CustomerTypeA, CustomerTypeB, CustomerTypeC as child classes. Would it be a better design to implement a ICustomer interface to Customer class and create sub type objects (CustomerTypeA, CustomerTypeB,…
Ramu
  • 343
  • 1
  • 6
  • 21
0
votes
0 answers

What is the design technique in the LocalDate.format() and LocalDate.parse()

In the java.time.LocalDate of Core Java 8, the format method is implemented as the following: @Override // override for Javadoc and performance public String format(DateTimeFormatter formatter) { Objects.requireNonNull(formatter, "formatter"); …
Rui
  • 3,454
  • 6
  • 37
  • 70
0
votes
1 answer

How Inversion of control, Dependency Inversion principle and Dependency Injection are related?

I know that using Dependency Injection/Service locator design pattern/etc. we are achieving Inversion of control. but where does the Dependency Inversion principle fit into? or it is completely separate than these 2? Do we achieve IOC using the DIP…
Girish
  • 166
  • 1
  • 2
  • 13
0
votes
4 answers

Good Sources for simple/gradual exposure to Design Patterns

I would like to set myself a goal to introduce myself to a new design pattern every week. Because I work at an internship right now, its hard to get me to do this because I always feel guilty that I should be doing work stuff & not learning a…
user593747
  • 1,484
  • 4
  • 32
  • 52
0
votes
1 answer

What is option–operand separation?

I recently read that option-operand separation is a principle that was introduced in the Eiffel language (I've never used Eiffel). From the Wikipedia article: [Option–operand separation] states that an operation's arguments should contain only…
Mark
  • 18,730
  • 7
  • 107
  • 130
0
votes
1 answer

Comments on my design v2

I posted not so long ago a class diagram for an application that I am making. Got some helpful tips and went to work. Designing sure is tough! Anyways, I made a version 2.0, but ran into other things. Maybe somebody could give pointers, or comments,…
TheDude
  • 197
  • 3
  • 10
0
votes
3 answers

Which Design Pattern use

Let's say I have a class products where I have a stock and can pay in 2 ways: Paypal or cash. I can only sell 2 products cash. This might change in the future so I don't want to have to change the whole code with ifs and else so I thought of using…
elkaco
  • 15
  • 6
0
votes
2 answers

Liskov Substitution Principle - Common Interface

I've been trying to figure out the Liskov Substitution Principle and Interface Segregation Principle and I'm a little confused with the following example. Assume that we have a base class called Vehicle with a couple of properties and a interface…
user1959214
  • 117
  • 1
  • 2
  • 7
0
votes
1 answer

Transaction involving external api calls

I'm having to implement operations on a repository-like class that needs to maintain consistency between a local database and external(third party) APIs. Some of those API may only offer partial success/partial failure semantics(i.e. non atomic) for…
0
votes
3 answers

Exception flow control

I use exceptions to flow control a lot, but I have a strange feeling that I am doing something wrong. Is it a good practice to write something like code shown bellow? public static void main(String[] args) { try { methodA(); } …
Milorad
  • 152
  • 2
  • 10
0
votes
1 answer

Difference between these python visitor design pattern implementation choices?

I was reading the implementing_the_visitor_pattern_without_recursion from Python Cookbook, Third Edition The implementation with additional Visit Class fix the defect in the one without it as it claims. “One potential danger of this recipe…
0
votes
3 answers

DAO as Service vs DAO as Library

I have 3 different services which needs to access same database. Each of these service will serve different purpose and different queries. I can generalize them in following way Service 1 -> Customer Inquires Service 2 -> Order Processor…
0
votes
1 answer

Which packages to place the @Entity Java beans and flattened Object beans (used only in Controller) is the most professional way?

As a yet "newbie" of JavaEE, say I try to implement a rather big RESTful API with Spring 4 and Hibernate and, the final JSON objects should be transformed to flattened Objects other than the original Java bean entities annotated with @Entity. Due…
Rui
  • 3,454
  • 6
  • 37
  • 70
0
votes
1 answer

Require Function Parameters Implement Method - Scala

Is there a way that I can require objects being passed in to a function implement a core set of methods? For example, I would like to be able to write a sum method to sum over any iterable of objects that implement the '+' operator. My initial…
CBlumey
  • 40
  • 1
  • 7
0
votes
3 answers

Almost identical recursive functions

I have a function called myFunction1 whose definition is the following: function myFunction1() { if condition1 then doSomething1(); myFunction1(); else if condition2 then doSomething2(); myFunction1(); …
Sotiris Kal.
  • 68
  • 1
  • 6