Questions tagged [patterns-and-practices]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
55 views

Chrome Extensions Best Practices. Put Functions in popup.js or background.js?

I am writing a my first Chrome extensions and it happened where all functionalities are triggered by buttons in the popup page. So I end up putting all of my functions in the popup. And my background ...
user avatar
  • 1
2 votes
3 answers
187 views

Is a method named createOrUpdate() violating the single responsibility principle? Should I split into create() and update()?

I work developing software, and very often I find inconsistency in the company's code. The thing is, there is a method named createOrUpdate(), and this method basically does what its name says, ...
user avatar
  • 49
-1 votes
2 answers
199 views

Would Injecting dependencies in C# as default parameters be a bad practice?

Given the (old) debate over whether Singletons are overused/abused/are worth it - would it be a bad idea to inject the dependencies as default parameters? In this way, we could get rid of defining ...
user avatar
  • 293
0 votes
2 answers
139 views

Best pattern/practice to execute a multi-step code generation process

I am working on a project that generates an API with the possibility of doing CRUD operations based on a high-level description of the resources that the user would like to have in an application. In ...
user avatar
1 vote
2 answers
197 views

Difference between Strategy pattern and Repository pattern

I found the following definition of Repository Pattern: Repositories are classes or components that encapsulate the logic required to access data sources. They centralize common data access ...
user avatar
  • 119
1 vote
1 answer
130 views

Free standing functions usable for Base pointers

I read multiple times that when a member function only uses API of class it is member of, then it should be made free standing and put in to same namespace, for example, bad practice: namespace A { ...
user avatar
  • 161
0 votes
3 answers
86 views

Should we test private data (static objects in this case) to make sure it maintains its structure?

I had a discussion at work about whether to unit test a private static object we're using as data for a public component. const data = { 45: { name: 'John' }, 2: { name: 'Patricia' }, 27: { name: '...
user avatar
-1 votes
1 answer
100 views

How to reconcile CD with major architectural changes?

(This question is inspired by the SO blog entry Fulfilling the promise of CI/CD and this old question of mine: Why is it wrong to comment out code and then gradually remove it to keep track of what I'...
user avatar
  • 3,327
0 votes
1 answer
83 views

Should I use SCSS mixins as shortcuts for default CSS syntax?

This question is mainly about readability and understanding of the code. Im am also in the process of creating a SCSS framework like Compass and Bourbon. I struggle to write SCSS because I like to see ...
user avatar
  • 11
23 votes
5 answers
7k views

Where did usage of OS signals go?

From what books I read on linux system programming, it seems like signals were the primary way to communicate events between processes. They were the gateway into many interesting functionalities, ...
user avatar
-1 votes
1 answer
189 views

Source of "... against the interface, not the implementation"

For a paper I am writing, I need to find the origin of the following two phrases: Code against the interface, not the implementation and Test the interface, not the implementation (Note: the ...
user avatar
  • 31.4k
12 votes
2 answers
3k views

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 ...
user avatar
  • 131
2 votes
2 answers
244 views

Understanding passwordless sign up for mobile apps

How does phone number based authentication work, and what are its best practices? I've noticed there are apps with streamlined sign-up/log-in processes where only a phone number is required, simply ...
user avatar
2 votes
4 answers
486 views

Confused about inheritance and correct usage. Should I avoid using members in base class?

I am using C++ , but as far as I understand most OO principles are cross language. In most of the articles that I have read and liked about inheritance the advice are about : not to use it for the ...
user avatar
0 votes
1 answer
161 views

Is it bad practice to run different versions of code in different environments? (i.e. test, prod)

As an example, let's say you have the following pseudocode: if test environment: # meaning you don't have the typical service account prod perms sudo as service account + do operation else: # in ...
user avatar
  • 103
1 vote
4 answers
109 views

Should I public method and test it instead of testing a caller

I have a method called GetValueA() and GetValueB() which return string that in formatted public string GetValueA(){ string a = service1.GetA(); return Format(a); } public string ...
user avatar
5 votes
1 answer
319 views

Methods with "With" prefix?

I started working on a project and I saw some methods with this With prefix and I'm wondering if this refers to a known pattern. Does anyone know of this naming pattern?
user avatar
0 votes
2 answers
91 views

Calling general-purpose methods from the code that clearly needs only specific behavior

Here are a couple of examples in Python: clearly_even = 2 * get_integer() print(solve_for_any_integer(clearly_even)) def solve_for_any_integer(x): while x % 2 == 1: x = make_even_from_odd(x) ...
user avatar
0 votes
3 answers
106 views

Strategy & Architectural Decision: Customer data migration between two companies

Asked this originally here, and didn't receive any answer so far, hence posting here too. Let's say company A acquired company B in a certain region. This means, A and B were competitors in that ...
user avatar
  • 109
1 vote
4 answers
214 views

When should a method depend on a data source and NOT have it declared as a parameter?

I was assigned a code review to one of my colleagues. I posed the following, which I wanted to share here in order to hear whether I am right or wrong. Consider the following code snippet: public void ...
user avatar
  • 293
6 votes
4 answers
533 views

Is there a standard name (or examples) for the "sandwich" pattern?

I've noticed a certain idea recur in different contexts, but before I start calling it "the sandwich pattern", it would be useful to know (in the spirit of other "Is there a name for ...
user avatar
0 votes
3 answers
175 views

Sysadmin password storing

I'm quite unexperienced in the sysadmin area. Now I'm facing the responsability of managing two (remote) servers. I'm working in an informal organization. So I have passwords for the OS's users, ...
user avatar
2 votes
2 answers
108 views

What pattern for translation is better, naming the key by screen/context or by text?

I'm in a dilema where I'm translation a full mobile app where the translations are going to be a key value pair but I'm not sure how to name the key. Should I name the keys describing what the text is,...
user avatar
  • 329
0 votes
0 answers
69 views

Can someone suggest what pattern I used mistakenly and is it correct in this situation. Any alternative?

Client_1 uses --> IService_1 and thus Service1_impl public interface IService_1 { void DoTask_1(); } public class Service1_impl : IService_1 { private readonly IDepService_1_v1 ...
user avatar
  • 181
1 vote
1 answer
103 views

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

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 ...
user avatar
  • 327
4 votes
2 answers
137 views

How should my application treat database collisions that are handled safely?

My applications uses error reporting to track exceptions. My application uses SQL transactions to make sure that operations are completed completely or not at all. My application is multi-threaded. ...
user avatar
  • 149
1 vote
1 answer
46 views

Deisgn Pattern: How to map UI requests to Controllers to Services?

I'm learning about writing WebApi design patterns. I am trying to create a simple CRUD web app with ReactJS UI and C# .NET CORE webapi with sql backend. Articles show that specific Repositories are a ...
user avatar
  • 21
4 votes
2 answers
105 views

Separation of data retrieval and processing in loops?

Often I need to get some data and process it in some way. For example getting a list of customers from an API and assemble some summary data on them. As an example, getting : api_result = api.request(...
user avatar
  • 1,511
2 votes
1 answer
210 views

Reusing aggregate root key across bounded contexts?

As the question states, is this bad practice? I have a User aggregate root in the bounded context of Identity for authenticating the user. In this bounded contexts I have fields for the User related ...
user avatar
  • 49
0 votes
2 answers
49 views

Logic in data provider vs test body

Lets say we have a class Cat: class Cat{ public eat(String food){ if (food.contains("cat")){ burp(); } } private burp(){ System.out.println(&...
user avatar
1 vote
1 answer
236 views

Communication mechanism among windows or pages WPF

I work with C# and WPF and not using MVVM approach. One of the important part of applications is communication among Windows Pages and UserControls. In MVVM they do it behind the scenes and let you ...
user avatar
0 votes
0 answers
54 views

What best practices/principles could help me improve my routine call placement?

I'm trying to change my module's outline since I feel I'm blocking some reuse possibilities, but I don't know how to justify it under the lens of good practices/design principles. Keep in mind this is ...
user avatar
38 votes
8 answers
9k views

Is it ok copying code from one application to another, both belonging to the same repository, to keep them independent?

Given a repository which contains two different applications A and B (e.g. bootloader and RTOS), is it ok to copy source code from A to B in order to avoid dependencies (include's, adding A source ...
user avatar
  • 605
1 vote
4 answers
266 views

Pattern / solution for Boolean decision making chains

I need a solution for decision making chain. There are number of criteria that may return true, false or be inconclusive. A non-functional code (Java) would look like this: Boolean res = ...
user avatar
  • 423
5 votes
2 answers
367 views

Is there a term similar to "upsert", but for the "find or create" case? [closed]

I'm wondering if there is a commonly used term similar to "upsert" or "merge" but for the case of "find or create". Ideally with a single word, something shorter that &...
user avatar
  • 367
-2 votes
1 answer
111 views

Patterns for multi tenant systems [closed]

Ok so first I want to describe the anti-pattern anti-practice. Company creates system for customer number 1. Then customer number 2 comes along they fork the codebase customize it. (Say for variations ...
user avatar
0 votes
2 answers
2k views

Unit testing private methods

preface: I know this topic has been asked about a lot on here in the past. Hopefully I will make it clear that I've read a fair amount of the questions/answers on the topic, and other literature, too. ...
user avatar
  • 3,118
1 vote
2 answers
125 views

Adjective for function types on wether the values are received or sent

I don't know how to phrase this better, but I remember reading an article about type theory, that categorized the values being received by a function and the values being sent back from the functions. ...
user avatar
1 vote
1 answer
133 views

Writing a SQL recordset as a HTML Table - a bad practice?

I'm maintaining an intranet using ASP Classic. Some of pages looks like one or more HTML tables used for administration tasks. Those tables are obtained by SQL requests. Server side, they are kind of &...
user avatar
  • 137
0 votes
1 answer
97 views

Should a payment success or error page expire?

When payment is made, it either succeeds or fails for whatever reason. In this case, though not important, the payment is made on a third party payment website, like Paypal, and a callback url is ...
user avatar
  • 113
1 vote
5 answers
659 views

Is this an anti pattern or misusing the interface default method?

Instead of checking the null and throwing exception each time we call findByOrderNumber method, I came up with this pattern by taking advantage of a default method, are there any patterns misused here ...
user avatar
1 vote
1 answer
89 views

Object oriented service best practice when changing a methods behavior for given context?

I expect this is a common problem and/or pattern question for beginners to OOP. Somehow I find myself wondering again and wasn't able to find a decent answer. So at the risk of creating a dupe... What ...
user avatar
  • 113
-2 votes
1 answer
118 views

Seeking a Pattern [closed]

First off, I totally understand that an interface cannot contain a static method because what would the method act on - that is clear. Suppose I want an interface to mandate a method that is ...
user avatar
1 vote
2 answers
692 views

Best way for resource (entity) relations loading in a REST API

We have a problem of load time in our REST API, which is the result of having Fat DTO (nested DTO s) & the N+1 problem (which is off my question), means that we are loading too much data in one ...
user avatar
  • 119
6 votes
2 answers
463 views

Is it a bad practice for a unit test to "trust" the other?

Assume I have the following two functions: function storeObject(object) { // Connect to database // Prepare query // Execute query } function retrieveObjectWith(id) { // Connect to ...
user avatar
8 votes
5 answers
831 views

Is it bad practice to add "false or" or "true and" to conditionals?

Is it bad practice to add false or ... or true and ... for the sake of promoting code genericness and/or ease of use? As in: SELECT * FROM table WHERE TRUE AND IsEnabled AND SomeField = some_value ...
user avatar
  • 197
-4 votes
1 answer
39 views

Microservices of different resource type

I am building a system composed of a few micro-services over AWS. I encountered the need of a certain MS to do the same logical work but of a big range of work load. for example, the same logical work ...
user avatar
2 votes
2 answers
469 views

Does it make sense to use meaningless named constants?

For example, does it make sense to refactor the following code: a = a * 2; as: const int INT_TWO = 2; // ... a = a * INT_TWO; My question hinges on the fact that the new constant conveys no ...
user avatar
2 votes
1 answer
183 views

What is the name of the throw-an-exception on invalid inputs pattern?

In some .NET libraries, there's a pattern of two alternative ways to call a function. int i = x.GetValue(k); /* Might throw. */ if (x.TryGetValue(k, out int i) { /*...*/ } else { /* ... */ } I ...
user avatar
  • 601
28 votes
9 answers
8k views

In software design, should an application remain agnostic regarding its usage with real world data / mock data?

Let me try to summarize a bit more with a simple example: You're building a large application, a user portal for example, with feeds, news, account management, and a whole range of difference ...
user avatar
  • 405

1
2 3 4 5
8