|
an idiot hell fucker posted:I myself have written JavaScript for more than three years without ever defining an object. The technique explained on this page is the first practical use of programmer-defined objects I've found. http://www.quirksmode.org/js/associative.html
|
# ? Jun 10, 2015 00:46 |
|
|
# ? May 27, 2024 12:58 |
|
fuckin' quirksmode
|
# ? Jun 10, 2015 00:47 |
|
Soricidus posted:I like the way java does file structure. one public class per file, one package per directory, names must match. it has downsides too and the visibility rules could be better but whenever I read about poo poo like f# I realise how good I have it Java being one of the very first PLs I learned, it always boggles my mind a bit when any language doesn't do this Perl has packages (code grouped by namespace) and modules (code grouped by file) being entirely separate things, then overloads the :: separator to refer to them alternately depending on context, or sometimes both at once You'd think this would mean developers, or at least CPAN module developers, would try to keep packages and modules harmonised so that nobody has to care about this distinction but NOPE
|
# ? Jun 10, 2015 00:50 |
|
Barnyard Protein posted:but it feels... not right because welding xml into the heart of your application is always a bad choice you can go the other way though; JAX-B and friends can use your data model when they [un]marshall
|
# ? Jun 10, 2015 00:51 |
|
quirksmode is a great place to feel ashamed of liking js
|
# ? Jun 10, 2015 00:55 |
|
I ask you, is there a worse code smell than people using "theValue" and "theStatus" for variable names
|
# ? Jun 10, 2015 00:59 |
|
uncurable mlady posted:quirksmode is a great place to feel ashamed of liking js http://www.quirksmode.org/js/function.html posted:This is a function:
|
# ? Jun 10, 2015 01:04 |
|
i've never seen quirksmode before. it's quite a thing
|
# ? Jun 10, 2015 01:13 |
|
Brain Candy posted:because welding xml into the heart of your application is always a bad choice yeah i've gotten as far as generating classes with xjc, and marshalling/unmarshalling with JAXB. i'm stuck at figuring how how to connect the generated classes, the model, to the view such that the view automatically updates when the model changes. maybe this is such a simple problem that the answer is obvious, idk.
|
# ? Jun 10, 2015 01:15 |
|
Barnyard Protein posted:who does the publishing then? the code that is making changes to the model (ie the controller)? the controller.
|
# ? Jun 10, 2015 01:17 |
|
really though you should be using wpf if your doing desktop development.
|
# ? Jun 10, 2015 01:18 |
|
the controller gets a request, figures out what the user wants, then finds the data the user wants, and shoves it into the view. you can also create viewmodels to house display logic for the model. this prevents you from contaminating your model with logic to do with display and removes logic from your view which can reduce maintenance woes for example if you have a model object that contains a list of things and if the list is empty you want to hide a section in the view. you could create the logic in your view to hide the section if list.size()==0 but you could also instead create a viewmodel that has a method bool showWhateverSection() that the view calls instead. any kind of logic or display that might be reusable you can put into the viewmodel to prevent having to deal w/ that logic in the view. of course if you're using something that supports partial views they make view component reuse easy so its not that big of a deal. but if you've got a person model object and in 15 different views you've got model.firstName()+" "+model.lastName() where you want the display name and suddenly you decide you want lastname, firstname instead of changing it in each view you just change it in the getDisplayName() method of you're viewmodel.
|
# ? Jun 10, 2015 01:27 |
|
Brain Candy posted:because welding xml into the heart of your application is always a bad choice jax b is fine but the scenarios where you're actively using jax b directly instead of as part of another framework (ex: cxf) are uncommon Shaggar fucked around with this message at 03:09 on Jun 10, 2015 |
# ? Jun 10, 2015 01:30 |
|
qntm posted:I ask you, is there a worse code smell than people using "theValue" and "theStatus" for variable names
|
# ? Jun 10, 2015 02:55 |
|
comedyblissoption posted:theStatus is helpful to differentiate the status in global scope as opposed to aStatus which is just in local function scope only when you are using tools that don't colorize that for you
|
# ? Jun 10, 2015 03:07 |
|
that doesnt help much when you need to print out your code
|
# ? Jun 10, 2015 03:25 |
|
here's a nickel kid, buy yourself an inkjet
|
# ? Jun 10, 2015 03:30 |
|
coloured ink is worth more than my blood by volume
|
# ? Jun 10, 2015 03:39 |
|
Switching between camel case, hyphens and underscores randomly is pretty annoying
|
# ? Jun 10, 2015 03:41 |
|
camel case is such idiot garbage prized by those who value screen real estate over being able to loving read anything im the idiot in the codebase who randomly omits vowels on identifiers for no loving reason
|
# ? Jun 10, 2015 03:43 |
|
Valeyard posted:Switching between camel case, hyphens and underscores randomly is pretty annoying why are you touching math code
|
# ? Jun 10, 2015 03:45 |
|
comedyblissoption posted:camel case is such idiot garbage prized by those who value screen real estate over being able to loving read anything Bloody posted:why are you touching math code
|
# ? Jun 10, 2015 03:46 |
|
a good name for a function is "f" when that's already taken, try "g" for local variables, consider "x" already used? give some thought to "y"
|
# ? Jun 10, 2015 03:50 |
|
xs and ys for collections are fine too btn and pn for button and pane are not fine
|
# ? Jun 10, 2015 03:51 |
|
cnt
|
# ? Jun 10, 2015 03:52 |
|
running out of letters? consider capitalizing letters. now you have twice as many possible variables.
|
# ? Jun 10, 2015 03:54 |
|
Bloody posted:running out of letters? consider capitalizing letters. now you have twice as many possible variables. This reminds me of another thing I hate, when the same variable is used multiple times in the same scope but for different reasons. Like at some point in the logic that value isn't needed anymore, so next time we need a new variable let's just use that old onwt
|
# ? Jun 10, 2015 03:57 |
|
Valeyard posted:This reminds me of another thing I hate, when the same variable is used multiple times in the same scope but for different reasons. Like at some point in the logic that value isn't needed anymore, so next time we need a new variable let's just use that old onwt haha don't you know this is way more efficient. learn 2 optimize scrub lord
|
# ? Jun 10, 2015 04:00 |
|
Soricidus posted:I like the way java does file structure. one public class per file, one package per directory, names must match. it has downsides too and the visibility rules could be better but whenever I read about poo poo like f# I realise how good I have it i only recently started using java, the last time i looked at it was in literally 1995, and there are still some mysteries to me about how packages and classes interact with files and directories, and how jars work with other jars and how any of the build systems work, but i really do like the discipline that it enforces
|
# ? Jun 10, 2015 04:03 |
I dunno, if your code is generic enough sometimes there's not really anything better to call your variables. Like if your function takes an arbitrary function as a parameter, why not call that function f?
|
|
# ? Jun 10, 2015 04:17 |
|
VikingofRock posted:I dunno, if your code is generic enough sometimes there's not really anything better to call your variables. Like if your function takes an arbitrary function as a parameter, why not call that function f? http://www.stat.unc.edu/faculty/hurd/stat185Data/progdoc.html click any link on this page
|
# ? Jun 10, 2015 04:19 |
|
Bloody posted:http://www.stat.unc.edu/faculty/hurd/stat185Data/progdoc.html there are actual comments in some of those files and they appear relevant
|
# ? Jun 10, 2015 04:28 |
Bloody posted:http://www.stat.unc.edu/faculty/hurd/stat185Data/progdoc.html Okay yeah those are bad, but click on any of these links: http://www.cplusplus.com/reference/functional/function/function/ http://www.cplusplus.com/reference/functional/bind/ http://www.cplusplus.com/reference/algorithm/copy_if/ http://www.cplusplus.com/reference/algorithm/is_partitioned/ http://www.cplusplus.com/reference/algorithm/find/ http://www.cplusplus.com/reference/algorithm/min/ http://www.cplusplus.com/reference/algorithm/transform/ The majority of the arguments to those functions are named things like 'a', 'b', 'fn', 'op', 'pred', etc, and it's perfectly readable. It's definitely not always a good idea to call a function 'f', but it's not always a bad idea either. I also think that in math/physics code, it's perfectly legitimate to give a variable a name like 'phi', 'theta', or 'rho' in a context where those have widely accepted meanings. For example if you have a function in some physics code which takes a point in spherical coordinates, it's totally cool to call the parameters 'r' (for the radial distance), 'theta' (for the polar angle), and 'phi' (for the azimuthal angle).
|
|
# ? Jun 10, 2015 04:42 |
|
Valeyard posted:This reminds me of another thing I hate, when the same variable is used multiple times in the same scope but for different reasons. Like at some point in the logic that value isn't needed anymore, so next time we need a new variable let's just use that old onwt seeing this also usually means the function is way too loving big function size too big should be a configureable compiler warning for all compilers comedyblissoption fucked around with this message at 04:45 on Jun 10, 2015 |
# ? Jun 10, 2015 04:43 |
Valeyard posted:This reminds me of another thing I hate, when the same variable is used multiple times in the same scope but for different reasons. Like at some point in the logic that value isn't needed anymore, so next time we need a new variable let's just use that old onwt Agreed, this is awful. Does anyone know whether LLVM can optimize away stuff like that? (my guess is yes)
|
|
# ? Jun 10, 2015 04:47 |
|
qntm posted:I ask you, is there a worse code smell than people using "theValue" and "theStatus" for variable names I have a coworker who uses it for singletons but I find it slightly ugh like if you have some get-only property with the same name as the class I already know it's a singleton VikingofRock posted:Agreed, this is awful. Does anyone know whether LLVM can optimize away stuff like that? (my guess is yes) One of the first rules of good programming is to write readable code instead of doing hosed up poo poo because you think it'll save something meaningless like a variable allocation. wait until a bottleneck becomes apparent before making sacrifices to readability/maintainability to improve performance. brap fucked around with this message at 04:52 on Jun 10, 2015 |
# ? Jun 10, 2015 04:49 |
|
trip report from ill-advised trip to x86 assemblyland: this is the worst poo poo but at least I can goatse people with a floppy disk on a 286 or better VGA-compatible PC how did anyone get anything done with this architecture
|
# ? Jun 10, 2015 04:53 |
|
VikingofRock posted:Agreed, this is awful. Does anyone know whether LLVM can optimize away stuff like that? (my guess is yes) any reasonable compiler for any reasonable language will optimize that away, yes. of course if we're talking about C, all bets are off (simple code? sure. crazy pointer manip the compiler can't reason about? lolol nope)
|
# ? Jun 10, 2015 04:53 |
|
VikingofRock posted:Agreed, this is awful. Does anyone know whether LLVM can optimize away stuff like that? (my guess is yes) optimize it to what?
|
# ? Jun 10, 2015 04:55 |
|
|
# ? May 27, 2024 12:58 |
|
Luigi Thirty posted:how did anyone get anything done with this architecture very carefully, lol
|
# ? Jun 10, 2015 04:55 |