1,869 reputation
49
bio website
location Illinois
age 44
visits member for 2 years, 2 months
seen 2 hours ago

Aug
29
comment Are C static libraries frowned upon?
@SK-logic: I don't disagree with your assessment of linker quality, but I wonder why things are thus? Unless an application is really huge, a 1GB machine should be able to load everything, link it entirely in RAM, and write out the result. Is there any reason linking shouldn't be fast?
Aug
28
comment Are null references really a bad thing?
In C, a variable of type *int either identifies an int, or NULL. Likewise in C++, a variable of type *Widget either identifies a Widget, a thing whose type derives from Widget, or NULL. The problem with Java and derivatives like C# is that they use the storage location Widget to mean *Widget. The solution is not to pretend that a *Widget shouldn't be able to hold NULL, but rather to have a proper Widget storage-location type.
Aug
28
comment FromXYZ vs Overloaded Method
@gablin: The name FromXYZ tells me exactly what the method should do: construct a new instance using information contained in an XYZ. By contrast, Load does not indicate whether it should modify an existing instance by replacing its contents with data from the indicated source, combine its contents with the source, or perhaps create a new object which has some properties of the existing object and incorporates data from the indicated source.
Aug
27
comment Overloading methods that do logically different things, does this break any major principles?
@back2dos: I was in agreement that the methods should not be distinguished by signature alone; they should be given different names. Where we differ is that in situations where the pattern: x.doSomething(f(y)) would be very common, I would favor having x include a method x.doSomethingWithConvertedObject(y) which will invoke x.doSomething(f(y)). If that pattern is common, the existence of that one-liner method will save code at every call site.
Aug
27
comment Is it a bad practice to use inline styling with generated code?
@MainMa: Since I was suggesting that the would be determined by the states of parameters, I thought that implied that they would be generated programmatically. If a server needs to generate a table whose cells' colors are individually assigned from among thousands of possibilities, saying <td style="color:#123456"> for each cell may be a bit bulky, but saying <td class="q123456"> and then having to ensure that class q123456 existed with attribute color:#123456 wouldn't be very concise either. I wonder why CSS didn't allow something less bulky than five-letter words "class" and "style"?
Aug
27
comment Overloading methods that do logically different things, does this break any major principles?
Having a method available which reads from a file, as well as a method which accepts a list of strings, means that client code which needs to supply a list of strings can do so, but that client code which simply has a file name need not bake in any assumptions about how the method will read data from that file.
Aug
27
comment Overloading methods that do logically different things, does this break any major principles?
@back2dos: load all words using something like wordList.LoadWords(System.IO.File.ReadAllLines(fileName));, adding support for binary file formats would require changing the client code.
Aug
27
comment Overloading methods that do logically different things, does this break any major principles?
@back2dos: The present implementation might read a list of strings from a text file, but that does not mean that does not mean that all future implementations would necessarily do so. Suppose it was decided that a future implementation should support a compressed binary data format. If the file-reading logic is encapsulated within a LoadWordsFromFile method, support for such a format could be added without requiring any change to the calling code [if the supplied file has a header that indicates compressed binary data, it could be parsed as such]. By contrast, if calling code had to...
Aug
27
comment Overloading methods that do logically different things, does this break any major principles?
...to tell the caller about additional files it needs. The only qualm I have with the load-from-file method is that its name does not make clear that it loads from a file.
Aug
27
comment Overloading methods that do logically different things, does this break any major principles?
@back2dos: I have no qualm with there being a method to build an object from a file. Requiring that the caller include code to open the file, pass the open file to the method, and then close the file requires duplicating exta code every call site, and makes the caller dependent upon the exact kind of file object being used. Further, in scenarios where a a primary document file can include references to other files which contain necessary data, the document-load routine is going to have to either know how to read those files, or else support a very complex interface...
Aug
26
comment Is it a bad practice to use inline styling with generated code?
@MainMa: What would be "doing it right"?
Aug
26
comment Is it bad coding practice to create something in a get if it does not exist?
+1 Generally, GetOrCreate is the wrong semantic but getting an object which may "logically" exist whether or not it phyiscally exists is fine. As an example, a sparse array of mutable items may not have any storage allocated for element 1,841,533, but still allow that element to be "retrieved" by creating a new object, storing it, and returning a reference.
Aug
26
comment Is it a bad practice to use inline styling with generated code?
What about cases where styling is semantically significant, e.g. labels are individually assigned to colors along a continuum which represent the states of some parameters, such that there are hundreds or thousands of different colors that might be used? If CSS allowed a class to say that a color should be computed from a function in a certain way, and then the HTML for individual labels could specify parameter values, that would be nicer, but I don't think that's possible.
Aug
26
comment Is method overloading anything more than syntactic sugar?
@cHao: I've never looked at non-toy-level Smalltalk compilers, so you may be right. On the other hand, a Smalltalk compiler supports constructs which Java cannot support efficiently, so the fact that Java's conditional constructs may not be necessary in a language which efficiently supports constructs that Java does not hardly means those constructs would be "syntax sugar" in a language which didn't support those other constructs.
Aug
26
answered Overloading Methods With Different Behavior - Style
Aug
26
comment Overloading methods that do logically different things, does this break any major principles?
Suppose version 1.0 of the API was created to accept a filename. Later it was necessary to allow words to be retrieved via other means. If one doesn't control all consumers of the API, one may deprecate the method which takes a filename, but can't safely eliminate it. The best path forward would probably be to give the method that takes data from another source a different name, but having a like-named method which accepts IEnumerable<String> would be understandable.
Aug
26
comment Is method overloading anything more than syntactic sugar?
@cHao: Perhaps instead of saying "similar values", I should have had "comparable overhead". I would be very surprised if Smalltalk could use virtual dispatch to achieve speeds that are within an order of magnitude of what Java can achieve, and constructs which make it possible to write faster code than would otherwise be possible are decidedly not syntax sugar.
Aug
26
comment Is method overloading anything more than syntactic sugar?
@Doval: I meant to use a value large enough to overflow in the multiplication to illustrate the danger of using overloads to control return types (when the argument was type double, the return was type long, but with an argument of type long then return is type int).
Aug
26
comment Is method overloading anything more than syntactic sugar?
@Doval: And what happens when you round a long?
Aug
26
comment Is method overloading anything more than syntactic sugar?
@cHao: if and while could be considered semantic sugar in a language which included for and break, or vice versa, but some sort of conditional construct is needed, and some sort of looping concept is needed. One could argue about which structure should be considered "fundamental" and which ones "sugar", but I would not regard as "sugar" a construct which cannot be emulated without adding flag variables, unless the compiler's own implementation would require similar variables.