« first day (503 days earlier)      last day (4434 days later) » 

9:02 PM
@tereško Do you have a CS/IT/other degree?
 
bachelors degree in CS , and unfinished/in-progress masters degree in IT project management
 
What do you think of your CS degree?
Like, the program?
 
i managed to get a very non-standard CS degree
the college i studied in got accreditation for the CS degree only in the last year i was there
 
Interesting.
 
so our program was more based on "useful shit to know" and less "government says that you need to know this"
 
9:07 PM
What languages were taught?
 
english , c/c++ , c# , java , a bit of 8086 assembler , a little bit php
 
it seems like true polymorphism without a "switch" or "if" statement in some factory class can only come from naming conventions and instantiating classes at run time like

$className = 'some_class_prefix_'.$variable;
$c = new $className;
 
Not at all.
 
please enlighten me. still wrapping my head around it all.
 
I assume you are watching one from Misko Hevery on Polymorphism?
 
9:12 PM
yes
 
He doesn't mean that your program doesn't use if or switches at all.
 
you seem to be misunderstanding what he says there a bit
 
well i know his first statement about "all if statements can be replaced by polymorphism" was hyperbole and meant to grab my attention
and also that its better to have the switch or other conditional in some factory class
 
That's the key point.
The factory/creator deals with creating the proper class.
The class does not try to juggle its behavior according to state.
 
@AndyPerlitch , the idea is that it is better to have one condition at the creation of the class , then have multiple ones all over the code
 
9:14 PM
@tereško Well said.
 
you have a conditional , which lets you decide , which class the object should have
 
ok i think im starting to get it. so lets say you want to add another subclass that you want to be able to instantiate. you have to add that subclass and also add a case in the switch, or elseif in the if statement of the factory
im just curious if there is any other way besides naming conventions to not have to add that extra conditional statement in the factory
 
the main question is : when to add a "subclass" and when you need a completely unrelated class , which implements the same interface
 
Well, a more elegant convention is to namespace it, and then use an autoloader to load the class.
Instead of string prefixing.
 
i think i had something on that subject
 
9:20 PM
namespace and autoloading are two concepts that i am also still struggling with but sort of get. namespaces arent available in php correct?
 
@AndyPerlitch As of PHP 5.3 they are
 
so namespacing basically allows for classes with the same name, just in different contexts?
 
something like that , yes
namespaces usually map directly onto folder structure
 
ok
ima keep goin with these clean code talks
yall are the fkn shit for helpin me out!
damn singletons are just the punching bag of OO patterns
 
because that pattern is not OOP
 
9:35 PM
^
 
"letting globals in through the backdoor" thats how one book puts it. im just gonna pretend i never learned what a singleton was
 
At least you will listen and learn.
 
@AndyPerlitch no, remember that you learned it. then remember that everyone who's not an idiot says it's evil. :)
 
Not everyone coming here will . . .
 
at least some fresh air while picking up the pizza
 
9:38 PM
which is not to say globals don't have their place. but an object shouldn't care whether it's global or not.
or whether it's the only one of its kind.
 
@cHao haha
 
@cHao I think the only two places I've used global variables were both written in C. One was for the MSP 430 and the other was my intro to threading project. The latter is not really a valid use-case, by the way.
 
well now i guess im curious when globals are EVER good to use? what about stuff like... credentials for a database connection
 
@AndyPerlitch Not really.
Globals are rarely appropriate.
 
@AndyPerlitch Depends on what you mean by globals there. You mean variables in the global scope or variables / values accessible globally?
 
9:42 PM
i cant say with absolute certainty that i understand the difference
 
@AndyPerlitch I'm glad you are man enough to admit it :)
 
What I mean is: It is okay (in my eyes) to have variables like $dbHost, $dbUser etc defined somewhere (in the global scope) and passed into a class. But it is not okay to define DB_HOST, DB_USER etc constants and just access them from everywhere (without passing)
 
if your thingie can change, it probably shouldn't be a global.
 
@NikiC ah ok i think i get it... damn ive been using the constant approach in my (naive) previous projects
 
i want to say it, btw...constants in php suck.
 
9:44 PM
@LeviMorrison haha yea man i think pride is what stops most ppl from getting better at anything
 
@AndyPerlitch A good rule of thumb of whether or nor to use constants is: Is it really constant? E.g. PI is a good constant. PI will never, ever change. But DB_USER is not a good constant as it can and will change (e.g. different users in dev and production)
2
 
mean, i might even be able to almost kinda tolerate them if i didn't have to go chopping up strings or calling sprintf in order to use them
 
@NikiC my little workaround for that was just have a config file that defines constants with a big if statement of whether the site was live, in testing, local, etc.. ay yay yay
i used them for holding paths to particular folders, as well as versions of js files and stuff like that. despite what i am starting to realize about globals and constants, it was nice to be able to just go into the config file and change main.1.1.js to main.1.2.js
 
@AndyPerlitch And it would be even nicer to automate all that ;)
 
@NikiC would you mind elaborating? or maybe there's an article/book/screencast/etc that you could point me to?
 
9:54 PM
@AndyPerlitch I mean that one could automate changing the versions :) Generally one can do lots of release automation.
 
googling release automation/release management =P
 
10:09 PM
@NikiC nice example!
But: The only constant is change.
So how could we deal with that? ^^
 
@hakre Right; and considering general relativity I'm not even sure that PI is constant...
 
@NikiC PI actually is not constant, it's endless.
 
@hakre But constantly so
 
@hakre , you are bad at grade school math
 
@NikiC EOL
@tereško It varied.
 
10:11 PM
At least in euclidean geometry. I could imagine geometries where pi is not constant :)
 
@NikiC , you sure ?
 
If you take the curve of time, PI probably will be fucking straight.
 
because tau describes 360°
tau = 2 * pi
 
@tereško With a lot of imagination...
 
Finally, in my apartment with Internet. I feel a little more sane now
 
10:15 PM
how to create a time portal in mac: open up local screen sharing on TWO macs:
FAIL
 
done that with team viewer , and rdesktop , and vnc , and xinit
 
how many years did you travel?
 
it's not so much traveling , as experiencing mild panic while you try to make your box responsive again ( and not restart it because you have an unsaved 10 page text document )
 
i was write in the middle of a PHP class, definitely understand
i finally restarted and it took like 5 retries to get it up and going.. haha
 
10:43 PM
anyone interested in code-kata ?
 
@tereško absolutely
 
been messing with it for past 2 hours
its not so much code-kata , as exercise in confusion
the officially given time : 30 min
it is actually one of 7 pre-interview tasks
 
class Foo
{
    protected $foo, $bar, $baz;

    public function __toString()
    {
        var_dump(get_class_vars($this));
        return '';
    }
}
echo new Foo;
what does this do?
 
i would assume that you get an array with 3 null values , but i am just guessing
 
it crashes PHP
 
10:51 PM
which one
 
for some reason it calls __toString in an endless loop
 
What's code-kata?
 
oO
 
@Gordon I think laruence fixed this and a related issue recently
 
@NikiC , it's not really code-kata what i have there
 
10:52 PM
i've ran it through my debugger to see why it kept crashing but i dont understand why it keeps calling __toString()
 
@Gordon Could you test on trunk and see if it works? I'm pretty sure that laruenced fixed exactly that issue.
 
@NikiC i dont have a trunk at hand and viper seems down/laggy again
 
@Gordon I have one, give me a sec
 
@NikiC thanks
on a sidenote get_class_vars requires a string. ive passed an object. but it shouldnt crash from that.
it works as expected when i pass a string or use get_object_vars with $this
 
This is interesting
It segfaults on latest trunk too
 
11:02 PM
@NikiC is that a bug then or is it just undefined because i didnt use the function as it is expected to be used?
 
@Gordon In any case it shouldn't segfault
Did you already gdb it?
 
aaaah!!!! I get it
it has to
 
ah, now I get it too
it casts to string...
 
get_class_vars requires a string, and i pass it the object. so get_class_vars will call __toString on the object because of the string context and that send it to the endless loop because __toString calls get_class_vars again with $this and goto 10
obviously my fault then
 
It still shouldn't segfault and instead throw a memory limit or oom error, but that probably won't get fixed ;)
 
11:05 PM
just saw that as well.
 
@NikiC you can fix it if you want :)
 
@Gordon If I want ... :P
 
You can fix it your own.
 
@hakre cant follow?! thats unrelated to the segfault
 
PHP never prevented unlimited recursion depth, didn't it?
 
11:11 PM
@hakre No. But in most cases you'll get a memory limit / OOM
 
What is an OOM?
 
out of memory
 
> Fatal error: Maximum function nesting level of '100' reached, aborting!
xdebug is sane.
 
@hakre depends
in most cases recursion is what you want
and that warning can really be annoying
 
Indeed, this is not covered by PHP memory limit.
 

« first day (503 days earlier)      last day (4434 days later) »