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.

0
votes
0answers
27 views

Does the function that operates on the object should return it?

Does the function that operates on the object should return it? Shortened example: class Example1 { public function method($a, $b) { $result = new Result($a, $b); $this->...
0
votes
1answer
88 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 = ...
0
votes
0answers
19 views

Storing data from a database vs continuous database retrievals [duplicate]

I've been searching for an answer across the web to my question but have not been very successful. I am creating an appointment scheduling program that uses a database to store a number of tables ...
2
votes
1answer
121 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
140 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
11 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 ...
0
votes
0answers
32 views

how to render data in different views that have a lot of similarities

I'm building an app in Angular, and here's an example of the problem that I'm facing: I have a place card, this place card appears differently and hold different data in different parts of the app, ...
2
votes
1answer
101 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. ...
-2
votes
0answers
25 views

Should subscriber contain application logic?

Should subscriber/listener contain application logic? For example my subscriber is listening Post object for send mail. Manage for sending (setting the recipient, sender, subject and content and ...
1
vote
1answer
93 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
100 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
359 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
149 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 ...
0
votes
2answers
36 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
158 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 ...
0
votes
0answers
47 views

How do I correctly separate the code that does three things and when to use events?

I have in controller: (pseudo code) public class MainController { public void accept(RequestData requestData) { Ticket ticket = this.generateTicket(); DB db = this....
2
votes
1answer
45 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 ...
0
votes
1answer
40 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
154 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
172 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
123 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
92 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
235 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
141 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
160 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
91 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
135 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
267 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
103 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
100 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
237 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
161 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
296 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
158 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
0answers
52 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
159 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
610 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
113 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
633 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
253 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
577 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
54 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
1k 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 ...
0
votes
0answers
46 views

Best practices to check permissions in a webapp based on api?

Let's say I build an api server and a angular/react/whatever client webapp. I can authenticate and store auth token, no issue with that. Is there andy best practice on how to handle users ...
9
votes
6answers
3k views

what can go wrong in context of functional programming if my object is mutable?

I can see the benefits of mutable vs immutable objects like immutable objects take away lot of hard to troubleshoot issues in multi threaded programming due to shared and writeable state. On the ...
111
votes
12answers
22k views

Why are multiple programming languages used in the development of one product or piece of software?

I am a recent grad student aiming to start my Master's in Computer Science. I have come across multiple open source projects that really intrigue me and encourage me to contribute to them (CloudStack, ...
4
votes
2answers
334 views

Should I duplicate code across languages?

Where I work, we use a language for our desktop software development (Delphi) and an other for web apps (asp.net/c#). My bosses want me to implement a feature on a website but they ask me to develop ...
1
vote
1answer
84 views

Scheduling Rules and Complexity in Coding Lots of rules respect to time?

We have some fields (age, visit type, insurance type, city) and some rules: Some doctors that define weekly schedule template like as: Doctor D1 works on Monday 7-9 pm , Thursday 7-9 pm. Some type ...
-2
votes
2answers
212 views

Should you make objects are generic as possible when planning out architecture?

I'm trying to improve my skills in planning out clean, modular projects with minimal coupling. Is it best to keep objects as generic as possible? If so, are there any pitfalls I should try and avoid ...