Questions tagged [patterns-and-practices]

Design patterns (repeatable solutions to commonly occurring problems) and best practices in software engineering

370 questions
54
votes
5 answers

Is "convention over configuration" not violating basic programming principles?

I was looking at the WPF MVVM framework Caliburn.Micro and read that a lot of standard things are based on naming conventions. For example, automatic binding of properties in the View to properties in the ViewModel. Although this seems to be…
Geerten
  • 1,135
  • 1
  • 8
  • 12
18
votes
5 answers

Combining getters and setters

JavaScript libraries such as jQuery, combine 'getters' and 'setters' in the programming interface for example: $('element').css({'color','blue'}); will set the color or $('element').css(); will get the css for an element. Is there a name for…
yannisl
  • 285
  • 3
  • 6
16
votes
2 answers

What is "lambda" code?

I have recently heard people talk about code being "lambda". I have never heard of this phrase before. What does it mean?
Oliver Moran
  • 279
  • 1
  • 2
  • 5
14
votes
2 answers

Code duplication vs. abstraction

I've inherited some research code where there's already a fair amount of code duplication: on several occasions, the original author duplicated a file and changed minor things to calculate a variation of the original problem. I'm tasked with making…
ohare
  • 151
1
vote
0 answers

Reuse and sharing with primitives

I am having trouble naming and thus searching for the right keywords for a pattern I am seeing in my web applications and their associated difficulties. Here are some examples of the pattern I mean: CMS: A page layout can have various regions in…
1
vote
1 answer

Who should log output, the ThingDoer or the code which calls ThingDoer.DoThing()?

Here's a common question I ask myself: If I have a ThingDoer class and it has a method DoThing(), and I want to log a message stating "Doing a thing", should I put this logging code in the ThingDoer.DoThing method, or should I keep this code outside…
vargonian
  • 327
  • 1
  • 7
1
vote
0 answers

When "cloning" an object in javascript should the clone behave as the original?

I'm using the webgl framework three.js. Most of the classes can be "cloned" via a .clone() method. Wikipedia seems to be very strict when it defines "cloning". In computer science, cloning refers to the making of an exact copy of an…
1
vote
0 answers

Making variables public in MVC pattern

In the MVC pattern, is it good programming practice to make all instance variables in the view(GUI) public so that the controller has easier access? I started to make setters and getters for everything but then gave up because it was way too many.…
William
  • 169
  • 1
  • 5
1
vote
1 answer

What is the minimal prototypical program to demonstrate the differences between the major programming paradigms?

Clearly the prototypical "Hello World" program does not suffice to demonstrate the difference between the major paradigms of programming. What would be the minimal program to show the differences between procedural, object-oriented, functional and…
1
vote
1 answer

Obsessed with filling hashmaps instead of using else if cascades or switch statements

Whenever I feel like choosing from a list of implementations I always prefer to fill a map first and then call whatever I need based on a parameter, instead of using switch or else if statements. What is the pattern I'm looking for here? I've been…
enon
  • 161
  • 6
0
votes
2 answers

Are support arguments passed to functions that help skip certain checks a trap?

Often times, through my framework's importing side of things, I have access to certain data that functions I'm about to use will certainly need themselves. I have "resolvers" that these said functions can use to get the additional data they need but…
coolpasta
  • 641
0
votes
1 answer

Is it bad practice to hard-code values in ASP.NET's web.config file?

I work for a company that is building a web application with ASP.NET & MVC, which was last worked on a few months ago. I am part of the team working on the project and have encountered values (such as place names) being hard-coded in the project's…
AStopher
  • 101
0
votes
2 answers

Statistics with SQL queries or in JavaScript

I have an excel like table with a should value and an is value for each day of a month: descrip. | | 01 | 02 | 03 | 04 | _______________________________________ column 1 | should | 60 | 0 | 60 | 0 | | is | 60 | 0 | 60 | 60…
devz
  • 243
0
votes
1 answer

How to design interface communication beween objects?

I'm stuck on a lightly philosophical question for me. I have three classes and I'm not sure how to make them related to each other. I have few competing approaches all of them standing on equal ground for me and I'm not sure which one has more cons…
edin-m
  • 133
-1
votes
1 answer

What should idempotent script do if resource changed?

I have a script that migrates data in the database. It copies property X to property Y. If I want the script to be idempotent, what should it do on subsequent call if X changed? For example: X is 'a' ==> I run the script, then Y is 'a'. …