New answers tagged

0

Yes and No. It Depends. Scenario 1: You are the sole developer on the project or its your personal project. Practices do not matter. What matters is that it works and its of good quality. Scenario 2: There are muliple people working on this project Yes it is a bad practice. Only required fields must be part of constructor parameters. Either use ...


4

Optional parameters is not a bad practice, definitely not, but sometimes the optional parameters may be optional solely because of what the class does. You arrived at a problem which is a result of a bad design. You are trying to figure out how to ignore certain properties of a model if you don't use them. The problem is, you are mixing responsibilities of ...


0

Having optional parameter constructors eliminates the need for multiple constructor overloads. In Java, there's an entire software pattern for this called the Builder Pattern, which essentially replaces multiple constructors with a fluent interface. It's an elaborate, overly complex and ultimately unsatisfying pattern; optional constructor parameters is a ...


1

If the language permits it, I would place it on the object it operates on. For example, you asks an Integer to convert itself into a Bound, so the conversion function takes place in the integer object. The same goes for Bound to Integer but this time, on the Bound object.


4

I'd take Robert C. Martin's advice on this one and make your code read like a newspaper article as he explains in his book Clean Code. Think of a well-written newspaper article. You read it vertically. At the top you expect a headline that will tell you what the story is about and allows you to decide whether it is something you want to read. The first ...


1

This is a matter of convention and not an absolute rule, but in my programming experience, helper functions should be at the top of the file, because they will be used later and so they are a prerequisite to understand the body. If a programmer wants to skip directly at a function that uses a helper, but didn't read the body of your helper, he will also be ...


0

In general, code should be written as it is intended to be read. Put your functions in the order that makes the code easiest for another programmer to understand them. That often means that the functions that get invoked first, such as main() and other high-level functions, should be early in the source file.


2

I'll give the author the benefit of the doubt and perhaps that is the way things are for Typescript, but otherwise in other environments that's a totally unsubstantiated claim that shouldn't be taken seriously. Off the top of my head, I can think of a variety of situations where passing data via constructor is good, some that are neutral, but none where it'...


0

I think it is depends on the context what kind of model that is being discussed here. I don't have Remo's book, but I guess that the model is a kind of service model, which needs to retrieve the data from a remote web service. If that is the case, being a web service model, it is better to pass all the data required as arguments in the web service's methods, ...


1

Using VS/Msbuild has the advantage of probably giving you a better IDE integration than third-party build tools. So for the main compiling tasks, you may consider to use the former - you typically get things like automatic positioning to the code line which caused an error during compiling. However, if you have already created some other tasks like "...



Top 50 recent answers are included