Tag Info

New answers tagged

2

tl;dr answer: DON'T. PHP supports parameterised queries; make the most of their ability both to handle all the nasty implementation details of converting dates between PHP and SQL forms, because it will be quicker to do so and far more solidly tested than rolling your own. In addition, you automatically get protection from SQL injection attacks that you ...


0

One advantage of these initializers that noone has mentioned is that they prevent silly mistakes: FileTransfer transfer = new FileTransfer(); transfer.ID = request.ID; transfer.SourcePath = request.DownloadLink; transfer.FileName = FileNameFromLink(request.DownloadLink); transfer.SourcePath = request.Destination; This will compile, and be buggy. ...


0

I agree with MainMa: group locally connected objects. In case there is no other connection, there is still the request / query: CusOrderDTO GetCustomerOrder(CustomerOrderQuery query) I add Request or Query to parameter objects.


1

I'd go with the function. Like you said, the first option introduces too much coupling. Option two looks okay but since your class will probably don't have to maintain state I'd go with option three. If in doubt, go with the easy/dumb solution ;).


2

If SomeParameterClassName regroups logically connected objects, then name it accordingly. For instance, if it regroups coordinate X, Y and Z, name it 3DPoint. If it regroups the product name, product price and product description, name it Product. void Demo(int x, int y, int z) { } ――― ↧ ――― void Demo(3DPoint coordinates) { } and: void ...


2

It's a guard or a guard function. The idea is that checks to make sure that some condition is true and then either continues or aborts the branching condition. It can also be regarded as a kind of filter function. This should not to be confused with guards as they are used in Haskell and other functional style programming languages, which operate more like ...


0

A Factory allows for the creation of objects that require complex setup code, or shared setup code across implementations. You should not perform the same complex setup in a constructor as a constructor is only intended to initialize an object and get it ready for use by setting member variables. The StackExchangeClientFactory.Create() implementation allows ...


2

You should assume that the server-side dataobjects use their own conventions, and the client-side would have its own. When fetching/posting data, you can set up a model adapter to handle switching between the two. By doing it at this level, each side uses their own conventions that make sense in each's contexts. After fetching your data from an ajax get, ...


0

Specificity - don't use a variable named variable unless it refers to something specific, like variable timing on an engine. Just don't do it. In a given context: Do not re-use variable names in a given context for different purposes. In a function, don't make variable = 'foo' for use as a string then later in the function make variable a numerical index ...


0

Reusing a variable is bad, because a compiler that would normally warn you about uninitialised variables etc. can't warn you, because at the time of the second use, the variable will be initialised. Reusing a variable name is usually not a problem. You may get compiler warnings if you create a variable with the same name as another variable in an outer ...


3

There are two entirely different things at play here: variable reuse and variable name reuse (redeclaration.) Your sample pseudocode does not make it clear which one of the two cases you are referring to, so I will mention both. This is variable reuse: int i = 5; for( ;; ) { i = 3; ... } This is variable name reuse: int i = 5; for( ;; ) { ...


1

If the variable is something simple and clear, like i, count, sum, go ahead and reuse it. If the variable is central to the method, like calculatedResult, or you are in a series of if/else blocks (or blocks all ending in return calculatedResult), reuse it. But if the blocks are not mutually exclusive, and control flows from one to the other, it might be ...


2

If the variable in question represents the same thing for both functions, I can't see why it would be a problem. If you're arbitrarily using variable to mean "any variable within a function that can do anything" then yes, it is a problem. Name your variables in the context to which they are used.


1

If the image you saw is like this one, D0-D7 imply bit positions in the status register, called F (for flags) when part of the AF register pair. The Ds are misleading because they imply some (nonexistent) relationship to the D register or the data pins (which are multiplexed with the address lines and are actually called AD0-AD7). Describing bit positions ...


0

In 8086 assembly that I learnt in Uni, D stood for data. There were four main register groups, AX, BX, CX, DX. Accumulator, Base, Count, and Data. And I suspect it didn't hurt that they were ABCD.


0

Yes there is difference d0-d7 are 8 bit data bus and D is one of the register in 8085


0

This is an old question, but I'm answering to disagree with the accepted (and only) answer. I've been a Java programmer for about fifteen years, and I've been doing it professionally and intensively for about three years. I initially resisted the mMember convention for all the abstract reasons commonly cited. But the longer I stared at Java code, the more ...


1

Please, use the standard conventions for each language (or somewhat very close to the standard). More consistency in each piece of software itself (because it will have the conventions that really apply) More ease for additional (external) fellow developers. They must not learn "inconsistent" styles. Easier comparison/review/transfer of code out of / into ...


4

Coding standards should be specific to the particulars of each language and platform. An idiom that is considered essential in C++ might be superfluous for another language such as C#. For example, you might insist of always placing a constant in an 'if' expression on the left (5 = x) to reduce the chances of accidentally having a single equals accepted as ...


6

Your software is an abstraction over the hardware. Whether a particular signal is active low or not is a detail you are supposed to abstract away. You should choose names to reflect that. set and reset probably feel odd because they aren't abstract enough. Try other verbs, such as as enable/disable, activate/deactivate, or select/deselect for a chip ...



Top 50 recent answers are included