Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [programming-practices]

Programming Practices are the commonly or not so commonly used practices in development of software. These can include things like Agile Development, Kanban, Coding shortcuts, etc.

-1
votes
0answers
34 views

How many request we can make at a time using “request” middle ware in nodeJS application

I am running a cron job every 5 mins to get data from 3rd party API, It can be N number of request at a time from NodeJS application. Below are the details and code samples: 1> Running cron Job every ...
128
votes
17answers
12k views

How do I know how reusable my methods should be? [closed]

I am minding my own business at home and my wife comes to me and says Honey.. Can you print all the Day Light Savings around the world for 2018 in the console? I need to check something. And I am ...
1
vote
1answer
125 views

Using “On” at the start of a method name

From what I've observed, methods that start with the word "On" fall into two categories: A base class that defines an event will expose a protected method whose name starts with "On" followed by the ...
1
vote
1answer
102 views

Where and how to connect to external API in my service class?

In my service class I would like to connect to external API. Where and how should I do it? 1) Inject in constructor ExternalClass and assign to private property. Next in other property in constructor ...
1
vote
1answer
35 views

Dictionary Application: Suggestions for serialization format and data structure

I want to create a dictionary application. One of the design guideline is performance in querying and showing up the definitions of words. I would like some suggestions on two design choices: Which ...
3
votes
3answers
169 views

Are there any drawbacks to using a nested class instead of declaring a new one?

I'm doing code review on a change my co-worker made to our Java application, and I've found something I'm not very familiar with - a nested class. From reviewing the code, it seems like the nested ...
6
votes
3answers
381 views

What is the term for a coding style which promotes subdivision of code in small, reusable, single-task functions?

Rather than writing a monolithic code, I've been taught to find the parts of code which can be reused (in the same code or in others) and create a function based on them, which should perform "one and ...
1
vote
1answer
31 views

NUnit specify TestCaseAttribute on implementation or create a test method

Based on this question about the correct usage of nUnit's TestCaseAttribute, I was wondering whether to specify the test case directly on the implementation or create test methods (as when using ...
90
votes
14answers
7k views

How can I avoid always feeling like if I completely rebuilt my program from scratch I'd do it much better? [closed]

I have learned a significant amount of coding, however, it's always been in a scientific environment (not computer science), completely self-taught without anyone to guide me in the right direction. ...
4
votes
0answers
130 views

Implementing new project to communicate with old ones. The correct way

I'm not sure if this is the right place to post this (I'm fairly new, but Stackoverflow and Superuser suggested this site for my question), but here goes. I currently have the following: A frontend -...
0
votes
1answer
153 views

Should the function that operates on the object return it?

Should the function that operates on the object return it? Shortened example: class Example1 { public function method($a, $b) { $result = new Result($a, $b); $this->...
0
votes
1answer
111 views

Can a class factory also save the object to a database?

How can a factory also save the object in the database? I want to create an object that consists of other objects. Pseudocode: firstObject = db.get....; secondObject = db.get....; expectedObject = ...
2
votes
1answer
125 views

How to say this statement correctly?

When reading code, how do you say the following statement? (It was taken from some C# code, could be many languages, though). List<string> Do you say: List of type string? or List of ...
-1
votes
1answer
153 views

Writing programs in an unsupported language

Is it possible to write a program in a language unsupported by an editor or IDE, save it, then run it in different IDE or editor that does support the language?
0
votes
0answers
12 views

Is there a best practices for roles with a Spring MVC web application on a host sytem?

Please be gentle on me as I am struggling to find a place to start. This question comes to mind when deploying a Spring MVC web app running on Linux. Everything I've read on deploying a Spring MVC ...
2
votes
1answer
107 views

How hard should I try to write idiomatic code in a polyglot environment?

I work on a small team (2 primaries with one or two other occasional contributors) on a project/product that spans a number of separate platforms. We do embedded firmware in straight C on Arm0 chips. ...
1
vote
1answer
96 views

How to ensure invariants, and is that even the right question?

A team created a structure like this (pseudo-code): struct Rectangle { int left, right, top, bottom; } Half a project later, the team realized that two thirds of the code was filling this ...
3
votes
1answer
103 views

Is good or bad practice to share reporting modules between systems/apps?

At my new work, a few people want to share modules between systems/apps, and I'm a bit skeptical about it. Context: we have a lot of little apps living in different servers, some of them are ...
3
votes
3answers
382 views

In functional programming, what it means “Order of evaluation does not matter” when function is pure?

In context of pure functions in FP, apart from several benefits mentioned like easy to reason about, testability it also says "order of evaluation does not matter" since output remains same for given ...
2
votes
1answer
152 views

What terminology is associated with uneven maintainability?

A developer is tasked with writing a service that will iterate through a number of records and send notifications for each one. The type of notification might be different per record, so you can ...
-1
votes
2answers
38 views

Web Services with Android and iOS apps

I have a website which uses REST Api for communication. All data retrieval and save happen through Rest Api calls(polyglot environment). Now I am planning to create an Android and iOS app . I have ...
1
vote
3answers
159 views

When implementing new features that are similar to other features, do you make the older features more generic?

This may come off as a bit confusing, but it's a question that I keep finding myself asking as I pile on more and more responsibility to older systems and features that I designed previously. Trying ...
2
votes
1answer
46 views

Balancer that delegates requests to servers and problem with Websockets

Lets have an application that has real-time chat feature. The chat requires websockets in order to function real-time. Now imagine we have "balancer" and 3 application servers. Instance of ...
-1
votes
1answer
41 views

Is it good practice to use data API for access cross platform

All, Question: Should I have a common data access API between various cross platform applications or keep the data access specific to the UI even though it would result in duplication? Background: ...
0
votes
1answer
162 views

If statement best practice [duplicate]

I am reviewing best practice with if statements. Below in example A I include the entire code to be run and ensure it remains within the if statement. While for example B the code to be executed ...
-1
votes
2answers
173 views

Dealing with software quirks

I was just reviewing some code and realised it is going to introduce the possibility for a situation where the numbers our staff use on a daily basis could be slightly out of line with the numbers we ...
-3
votes
1answer
126 views

Should I directly use pre-built codes on Github? [closed]

I need to know if is it correct to use pre-built codes on Github, or try to build it my self, while even I tried to build it I think it won't be as proffissional as that one on Github... the point is ...
1
vote
1answer
98 views

UI in code behind vs UI in specific view language/markup

I have heard some developers say they prefer to build their UIs in code behind... I am of the opinion that this leads them to write really bad code... Super large functions, spaghetti code, and mixed ...
1
vote
4answers
243 views

What should be the last entry in a switch/case statement?

When writing a switch statement that only ever has to deal with a known set of values (imagine an implicit enumeration), I find myself wondering what should be the last entry in the construct. I'm ...
2
votes
2answers
166 views

The dilemma of implementing virtual inheritance

I am working on a program language, and I came to the dilemma whether it should support virtual inheritance or not. As a designer and implementer of the language, including that feature represents ...
3
votes
2answers
165 views

Persuading management that good software engineering is worth the effort [duplicate]

Background: I work for a small company which does not have a set of established best practices for designing software. I was hired to work on a project which gathers data from a stream, does some ...
2
votes
1answer
102 views

How to optimize a complex task with multiple DB calls

I have been working on a multi-layer, sale management application developed with WPF and partly refactored with EF6 (long story). The application has some very complex tasks which require multiple ...
0
votes
2answers
137 views

Building dynamic code that can still handle many one-offs?

So we're having a rather heated debate at work as to what would be the best practice going forward while refactoring our reporting system. Most of us have some strong opinions one way or the other, ...
1
vote
3answers
272 views

Bug-preventing vs clean code

If I'm faced with the decision to write clean, beautiful code, but I'd be opening up a new path bugs could take to appear, should I take it? (Provided I'm not willing to spend the time to come up with ...
1
vote
1answer
114 views

Large executable size due to libraries/frameworks

My question sounds a bit dumb. Usually we are suggested to use existing libraries or frameworks, to avoid reinventing the wheel, or to achieve some "good practices" (e.g. during software distribution)...
1
vote
2answers
103 views

My implementation accepts only URLClassLoader, may I be less restrictive in my method signature?

I wrote a Java API that accepts ClassLoaders as parameter, even though it won't accept any ClassLoader that isn't a URLClassLoader (because I'm only interested in the URLClassLoader::getURLs() method):...
0
votes
1answer
326 views

Passing an inputStream vs String [closed]

I have a file on the disk. I want a clear distinction of responsibilities between my reader and parser. The reader reads the file and extracts the content as a string. This string is input to the ...
-6
votes
3answers
163 views

Why do languages distinguish between arguments and parameters?

Also, if my argument and parameter are the same value can I just use the same identifier for both? Thanks
0
votes
1answer
446 views

Best design pattern for Notification System => How to handle multiple languages and items

As always I came here to ask for some light in a design issue I am facing. I have a system that issues some notifications : PackageReceivedNotification PackageSentNotification ...
1
vote
1answer
165 views

Limitations of using classes as interface

I am an Electrical Engineer now training and working as an embedded software developer, so I have little formal computer science and software design training. I have until a few months ago only worked ...
0
votes
4answers
138 views

Best practice to populate a `container` class

lets say I have several objects Object A,Object B,Object C in different parts of my project. I have defined a Object X that is only used to store some specific values from the objects mentioned above ...
0
votes
1answer
219 views

Advantage or disadvantage of using = operator or uniform initializer while using auto keyword

Most examples of auto use the = operator. #include <iostream> int main() { auto a = 1; std::cout << a << '\n'; } Why don't they use the uniform initializer like this? #...
-1
votes
1answer
761 views

Generic method with different arguments

In the following scenario: A factory returns an object of a logic class: ILogicClass object = factory.GetByRequirements(reqs); I then want to invoke a method and get some results which are in the ...
0
votes
1answer
135 views

Why “typeof null == object” will stay in javascript?

I was reading a article about front-end development on Medium, when I stumbled upon an interesting piece of information, which is as follows: The type of a variable can be determined by using the ...
12
votes
5answers
636 views

In what conditions (if any) is it good practice to query two servers and only consume the fastest response?

I've asked what is now a deleted-by-Community question on SO on why would someone use javascript's Promise.race, and a high rep user commented this: If you have two services that compute some value ...
-1
votes
2answers
256 views

Does reading over code I've written make sense to verify it?

After writing some code, I have a habit of scanning it all over once or twice in order to look for any bugs. This is sometimes a painstaking and tedious process, and it takes up time. After reviewing ...
9
votes
4answers
579 views

Hiding/disabling features for some users

Lets say I have a free and paid version of the app. Paid version is a superset of the free version regarding features available to users, meaning paid version will have all the features of the free ...
-2
votes
1answer
62 views

Trying to find a quote — when you find a bug, fix all occurrences of it

I vaguely remember a quote from, IIRC Kernighan. Something along the lines of: when you find a bug, fix all occurrences of it I think it was either in the "Practice of Programming" or "The C ...
2
votes
1answer
55 views

How to select every x% of records for processing

I'm processing a stream of incoming records, for clarity assume they're numbered consecutively 1,2,3....etc. Most of the time the records are arriving slowly enough for me to process every single ...
7
votes
7answers
2k views

Best practice to “continue” from inside a nested loop?

Here is a simplified sample. Basically, it does checks on a string from a string list. If the check passes, it will remove that string (filterStringOut(i);), and it is no longer ...