Tagged Questions
0
votes
1answer
90 views
What design pattern should I use for import, update, export
I need to create a simple payments validator. On the following class diagram, I tried to present the model of payments. As you can see, each payment type inherits from Payments class.
Now I want ...
0
votes
0answers
53 views
Creating New Wrapper Objects and Extension Classes and Keeping it Organized
Here's my situation:
I'm programming an embedded device with a very simple, but customizable LED array display. It's 10 RGB LEDs linearly setup. The LEDs will be used to display many different ...
13
votes
4answers
951 views
Which way to terminate reading loop is the preferred approach?
When you have to iterate a reader where the number of items to read is unknown, and the only way to do is it to keep reading until you hit the end.
This is often the place you need an endless loop.
...
13
votes
9answers
4k views
Are too many if-else statements for validation bad? [duplicate]
From the book Professional Enterprise .Net, which has 5 star rating on Amazon that I am doubting after having a read through. Here is a Borrower class (In C# but it's pretty basic; anyone can ...
6
votes
5answers
431 views
Why would a developer create a public class that has all static properties?
A previous developer has a couple public classes that do not inherit from any other classes but are filled with static properties. Is this another way of creating a struct or enum? Is this an older or ...
6
votes
3answers
476 views
Is 'using' appropriate in a context where there is nothing to dispose?
In C#, using statement is used to dispose in a deterministic manner the resources without waiting for garbage collector. For example, it may be used to:
Dispose SQL commands or connections,
Close ...
13
votes
2answers
1k views
What is the best approach for inline code comments?
We are doing some refactoring to a 20 years old legacy codebase, and I'm having a discussion with my colleague about the comments format in the code (plsql, java).
There is no a default format for ...
10
votes
5answers
3k views
Why have a method that returns a bool/int and has the actual object as an output parameter?
I see the following code pattern all over the place in my company's codebase (.NET 3.5 application):
bool Foo(int barID, out Baz bazObject) {
try {
// do stuff
bazObject ...
19
votes
8answers
1k views
Adding complexity to remove duplicate code
I have several classes that all inherit from a generic base class. The base class contains a collection of several objects of type T.
Each child class needs to be able to calculate interpolated ...
7
votes
2answers
512 views
Are there any opensource APIs that help analyze code?
As an example, let's say that I need to check for a certain usage of C# code and warn the user that that is a bad pratice. There are multiple usages that I want to detect, such as:
Resource not ...