« first day (1724 days earlier)      last day (3260 days later) » 

10:23 AM
thank you
 
hi
 
so you had questions about Javascript objects?
 
If I ignore proto inher, how would you create obejcts in javascript?
yes
 
the simplest way is using object literals, which I believe are basically the same as Python dictionary literals
var x = {
d_number: 3,
d_foo: function() { return this.d_number; }
};
and this is essentially the same thing as the first code snippet in your question
 
10:27 AM
so you created an object with its state(value 3) and behaviour and x point to that object
correct?
 
yep
 
I believe most dynamic scriping languages allow this to some degree
JS also has some syntactic sugar; instead of a "class" keyword when defining the class it has a "new" keyword when constructing objects
 
If you are writing similar code for account, then I would say creating abstraction account using objects, corrct?
 
typically you'd use it like this:
var Foo = function(initialValue) {
this.d_number = initialValue;
this.d_foo = function() { return this.d_number; }
}
var f = new Foo(3);
var g = new Foo(5);
I'm not sure I know exactly what you're referring to there but something like that yes
a more typical phrase might be using objects to encapsulate the account's data
 
10:32 AM
when I say abstraction, it is the method to create barrier between representation and usage
 
incidentally, prototypal inheritance simply turns that example into this:
var Foo = function(initialValue) {
this.d_number = initialValue;
}
Foo.prototype.d_foo = function() { return this.d_number; }

var f = new Foo(3);
var g = new Foo(5);
 
in my first code represe is dispatch = {'balance': 0, 'withdraw': withdraw, 'deposit': deposit}
 
sure, that specific type of abstraction I'd normally use "encapsulation" for, but all these terms are vague buzzwords so whatever works for you
not sure why I was using the d_ prefix on a public method in those examples, but too late now
 
so how do you introduce inheritance with such first approach?
Did you get my question?
 
the short answer is that prototypes are transitive, iirc you can do something like Bar.prototype.prototype = Foo.prototype and then doing Bar.d_foo will eventually find d_foo on Foo's prototype
I forget exactly how this works because almost no one "hooks up" prototypes manually like that, even in plain Javascript we rely on Object.create() to do that part
 
10:42 AM
python syntax would help me, because we do not have prototype concept in python
Is prototype concept introduce to provide ineritance in javascript?
 
yeah, prototypal inheritance is unusual, I'm pretty sure Python does not have it
Javascript is probably the only "mainstream" language using it
it has a lot of strange and interesting consequences that can be useful or dangerous
 
I see that you introduce the attribute(d_number) without prototype syntax but method Foo.prototype.d_foo = funtionc(){}. why is that?
 
"without proto"?
ah
the difference is that there is only one prototype, even when multiple objects share that prototype
if I did Foo.prototype.number = 3;, then there would only be one "number" shared among all instances of Foo, which is not what we want
whereas for a public method, we typically want there to be only one implementation shared by all instances of Foo, rather than each Foo object carrying around its own separate implementation
 
ok
some thing like static member in java class
 
partly for performance reasons (all those extra function literals waste time and memory) and partly because those are the desired semantics
the static analogy unfortunately does not work; static methods are called without any object instance to be called on
a method on the prototype chain still is being called on a specific object
 
10:48 AM
ya
 
you can see why people might find this weird and confusing
I have to go now, but one last thing I wanted to mention
 
Bar.prototype.prototype = Foo.prototype looks horrible syntax to learn as a beginner
ok
 
you can also add things to the prototypes of built-in object types in javascript, eg
Array.prototype.getFirst = function() { return this[0]; }
whether this is useful or extremely dangerous is controversial
yeah, use Object.create()
g2g now
 
ok thank you
 
 
2 hours later…
1:00 PM
ugh do not use inheritance in JavaScript..
Next time you get the hankering to do so, stick yourself with a pin until the sensation passes
 
it's pretty rare for me to use inheritance in any language; in Javascript I think I've only ever done it when someone else's API forced me to
being able to pass function literals around is just so much more flexible and expressive (at least with what I'm doing)
 
 
2 hours later…
user55340
 
user55340
3:30 PM
could use delete votes... everything is closed.
 
5:07 PM
I'm voting to close this question as off-topic because it is about legal issues, and Stack Overflow is not in the position to give out legal advice. It might be better on Programmers Stack Exchange instead. — Kevin Brown 26 secs ago
 
5:22 PM
We do accept some licensing questions on Programmers.SE, but most legal questions are off-topic, because we aren't equipped to give legal advice either. This one might be okay, though it seems to have gotten a good answer here already. — Ixrec 1 min ago
 
 
2 hours later…
7:28 PM
38
Q: Would you purchase hardware with your own money to use at work to do your job better?

instaAt work, I was given a reasonably-spec'ed machine (dual quad 2GHz, 4GB RAM, 160GB 7200RPM drive, Win7), but it was lacking in a few places (HDD / RAM). The IT staff was OK with me replacing hardware with my own, so now I'm sporting an SSD and an extra 8GB of RAM (so I can run multiple Visual Stu...

^^ the last with no CVs on it.
 
no I would not
and unfortunately I already used all my CVs on today
 
@Ixrec I had 7 left after my 20 reviews and I used them on 7/8
I want to kill the small tags quickly so it makes my life easier to make the status post ;)
 
for some silly reason I expected work-environment to be one of the smaller ones
tomorrow I'll check a few more before picking a target
 
Well the number is there in the status post
 
I started from the meta thread
 
7:32 PM
Yeah I've been using the chatroom to keep the numbers. I don't think Thomas wants me to put numbers in the meta thread because he's edited them out in the past.
probably because they never stay accurate for more than an hour.
plus, these links have "closed:no locked:no", which they don't have in the meta thread.
 
yeah, I know all these things, I don't know why I didn't use the pinned chat links today
probably juggling this with too many other tasks
 
@Ixrec I hear ya
 
8:06 PM
can we please point some... X-rays towards this "question"
 
I have done what little I can (downvote)
 
8:38 PM
0
Q: How can I learn WPF Adorner

George OkpeJust like the topic, I would like to learn how to use Adorners in WPF, but all the online resources I see only try to treat a particular problem and do not actually teach you to learn, I have taken a look at the MSDN site, and I do not really like it

 
user55340
9:30 PM
Heh...
 
user55340
Question from '10 was reposted here (back in '10) and never closed on SO...
 
user55340
1
Q: Required skills for a senior level ActionScript/Flex developer

wajiwI'm looking to take my Actionscript knowledge to the next level and I've been having trouble finding what it takes to become a senior level AS developer. From my searching this has what I've come up with so far: Component Creation Memory Usage Debugging/Profiling AS specific usage of OOP Corre...

 
user55340
1
Q: Required skills for a senior level ActionScript/Flex developer

wajiwI'm looking to take my Actionscript knowledge to the next level and I've been having trouble finding what it takes to become a senior level AS developer. From my searching this has what I've come up with so far: Component Creation Memory Usage Debugging/Profiling AS specific usage of OOP Corr...

 
9:44 PM
ChrisF edited the STCI tag out of this one, but didn't historical lock it and left it pending:
109
Q: You're hired to fix a small bug for a security-intensive site. Looking at the code, it's filled with security holes. What do you do?

DokkatI've been hired by someone to do some small work on a site. It's a site for a large company. It contains very sensitive data, so security is very important. Upon analyzing the code, I've noticed it's filled with security holes - read, lots of PHP files throwing user get/post input directly into m...

 
gawd, Android development is so clunky
 
@AshutoshNarang you could accept the answer that you think worked better for you, it seems that the one you accepted is the one that worked, but also remember that this site is visited by programmers seeking for solutions and they often use answers from previous questions. — iharob 6 secs ago
 
Anonymous
10:00 PM
@André battling with the slow simulator?
 
Anonymous
also, good evening everyobdy
 
evening
 
Anonymous
does anybody write and understand perl?
 
Anonymous
I'd ask around in SO, but most of those folks only do JS/any other language that became popular after 2005
 
I don't, but if no one in here does you could try the PPCG guys chat.stackexchange.com/rooms/240/the-nineteenth-byte
 
Anonymous
10:09 PM
hmm codegolf... how could I forget that last bastion of perl programmers haha... thanks!
 
it's literally the only place I've ever seen people write actual Perl code =)
 
Anonymous
@Ixrec haha well... code golfing doesn't exactly encourage people to write modern and correct perl
 
I used perl like 15 years ago
 
Anonymous
@Telastyn have you ever had to deal with one of the most typical problems? ie: parse this html table
 
10:29 PM
@PatoSáinz, battling a non compliant JRE, so many edge cases
 
It would probably be better fit at Programmers SE — michaelpri 35 secs ago
 
Just use a regex @PatoSáinz
 
@PatoSáinz - no, did mostly command line automation stuff. I expect cpan has a hojillion html parsers.
 
Anonymous
@André oh god you have to see the table I'm trying to parse
 
Anonymous
it's a bloody mess
 
Anonymous
10:32 PM
of course I've done my homework with HTML::TableExtract, other modules and web services
 
Anonymous
hell I even searched if IBM Watson had a table churning service
 
Anonymous
there's an example table
 
Anonymous
it's a mess
 
Anonymous
what I want to produce out of that table is, for example, a nice array with all the grades (under the "NotaX" headers) of a given subject (say, "Matemáticas")
 
Anonymous
10:34 PM
@André cue the typical StackOverflow: "don't use regexes for HTML" advice
 
It was a joke :-)
 
Anonymous
@André hahaha I see
 
I don't want cthulhu waking up
 
doesn't seem that substandard
 
Anonymous
@Telastyn so how would you tackle it? I don't know where to start
 
10:38 PM
grab some lib to parse the html into bits, write a little bit of code to extract the data I want from the tree, liberally hardcoding "there will be one table, and I expect it to be in this shape" logic
 
Anonymous
@Telastyn can you please elaborate more into your idea? It's been over a year since I last wrote code and I'm kind of starting slow
 
so I expect to be able to find a library for most any language that will give you a tree from the parsed html
html -> body -> table -> ...
 
Anonymous
yes, there's a library like that
 
I would then write some code akin to: "find first table in body (or explode horribly); Get rows 1-max (assuming first row is header); For each row, find first child of each cell that has content (as opposed to tags) and add to list"
very literal
very fragile
run, compare output to expected and tweak as necessary.
import data, then discard code.
 
Anonymous
luckily, all the tables I have to parse are in this exact same awful form
 
Anonymous
10:43 PM
so one literal fragile script is all it takes
 
Anonymous
if only I had access to the database that spews out that data
 
Anonymous
there's not even an API so I mean... actual DB access
 
shrug if it were nice, it'd be done already.
 
Anonymous
@Telastyn even the tables some of the obscure USGov sites show you aren't as horrible
 
shrug
 
11:10 PM
This question...
0
Q: Are the Repository Pattern and Active Record pattern compatible?

marcanuyCurrently I am developing a webapp where I have defined models implementing the Active Record pattern. Each model also is defined by an interface that specifies the Entity properties and makes it easy to inject it into other classes, specially useful for unit testing. I am looking forward to impl...

He's talking about injecting a data access mechanism into a repository, so that the repository can retrieve data from the database. But if you want to do that, you would have to write your data access mechanisms to conform to a particular interface so that you could inject the desired one into the repository.
The repository is the place where you define your API for the consumer. So, rather than have some sort of IRetrieve interface that the repository accepts into the constructor, wouldn't it make more sense to have separate IRepository implementations, each of which uses a different database access mechanism?
In other words, isn't an API that conforms to some IDatabaseRetrievalMechanism interface essentially the same thing as a Repository?
 

« first day (1724 days earlier)      last day (3260 days later) »