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
2 answers

Liskov substitution Principle and Virtual Method

I have scenario where a virtual function is overridden in derived class with additional pre-conditions. Here is the snapshot - class Process { protected virtual void ValidateDates() { if (Entity.StartDate.Date > Entity.EndDate.Date) …
vibhu
  • 1,657
  • 2
  • 15
  • 19
1
vote
1 answer

wcf best design principles

I am looking to make some changes to an existing WCF service. I wanted to know if it would be best to make super methods such as a Save() that would use the values received to decide what action to take or if I should break the actions out into…
Tony
  • 3,269
  • 1
  • 27
  • 48
1
vote
4 answers

Where to validate variables (to make it a well designed pattern)?

Lets say I have an index.php file and some $_GET variables. After a few hundred lines of code I call a method, with the variables as parameters. Should I validate the variables on top of everything, or should I validate them inside the class/method…
Daniel W.
  • 31,164
  • 13
  • 93
  • 151
1
vote
2 answers

Duplicating data in database - web application project

Me and 2 friends are starting a project, simple social web app. The problem, that's troubling me is that we have a table Wallet, which will store sum of all transaction values between two users. TABLE…
emsi
  • 51
  • 4
1
vote
1 answer

Factory Pattern implementation coupled with reading and writing

I'm trying to design application in right manner, it should Read invoice data from SQL Server (2 queries depending on type of invoice: sales or purchase) Process it (Acme may need less fields than SugarCorp and in different formatting) Output…
netdis
  • 321
  • 3
  • 12
1
vote
0 answers

Design Principles for a Better Content Management System

May be the question is so simple for you. But many times I feel it is much complicated. Everyone would have started their website with a custom cms and later moved to Wordpress, Drupal, Joomla or something similar. I used to look for a better book…
Hari K T
  • 4,174
  • 3
  • 32
  • 51
1
vote
1 answer

Design Pattern For "Load Format Save Data"

I need to acomplish things like loading data from xls source (ole db), formatting it according to specification of output file, merging proccessed fields, then saving it to csv. How to handle multiple fields of data that must be of certain type?…
netdis
  • 321
  • 3
  • 12
1
vote
8 answers

Which design option is more suitable for auto-correction on construction?

Trying to decipher an appropriate OO design to implement. The basic scenario is that you have a PstnNumber which is essentially a 10 digit phone number that always starts with 0 (e.g. 0195550000). A rule has been introduced to allow auto-correcting…
Student for Life
  • 1,023
  • 1
  • 9
  • 18
1
vote
2 answers

What is design principle behind Servlets being Singleton

Possible Duplicate: Why is (javax.servlet.)SingleThreadModel deprecated? A servlet container "generally" create one instance of a servlet and different threads of the same instance to serve multiple requests. (I know this can be changed using…
Sandeep Jindal
  • 14,510
  • 18
  • 83
  • 121
1
vote
1 answer

Confused about the law of Demeter principle

To explain my problem, let me show you the example code with C#. interface IConstructorInfoSelector { //ConstructorInfo is System.Reflection.ConstructorInfo class. ConstructorInfo SelectConstructorInfo(Type declaringType); } class…
Jin-Wook Chung
  • 4,196
  • 1
  • 26
  • 45
0
votes
0 answers

“Never alter or delete a user’s work without them knowing” - is there a name for this software design principle?

Is there a software design principle that says an application should never alter or delete a user’s work done in the application without them knowing? It’s very similar to the Principle of Least Astonishment, but specifically referring to modifying…
user3163495
  • 2,425
  • 2
  • 26
  • 43
0
votes
1 answer

Spring application events without extending ApplicationEvent

Is there any way to define custom application events without extending ApplicationEvent? We are having submodules based on ports and adapters principle, domain module not having any any external dependencies like spring-context. And application…
sidgate
  • 14,650
  • 11
  • 68
  • 119
0
votes
1 answer

When we use class methods as setter to input object

What principle are we violating if we use a method to update an input object's fields? An example: class Data { public int $someField = 0; // it's private with setSomeField method public int $anotherField = 0; } class SomeUseCase { // ...…
NameX
  • 49
  • 4
0
votes
1 answer

Identify the best architecture for sending different types email in ASP.NET Core

I have defined an interface IEmailManager as having send method. The email controller is using its concrete type EmailManager as a constructor dependency that sends the email. public interface IEmailManager { void SendEmail(); } public class…
0
votes
1 answer

Best practice to create nested objects

I always have the same question when I must to work with nested objects structure. An example: class Criteria { filters: Filter[]; } class Filter { field: string; operator: Operator; value: string; } class Operator { operator: '=' |…