« first day (1751 days earlier)      last day (3197 days later) » 

10:00 AM
@HassanAlthaf what's neat about OrientDB's data model, is, writing a data-mapper would be essentially a matter of mapping data-types, no object/relational mapping needed, since the data-model already fits with classes, inheritance, and structured data-types like arrays and maps supported as property (column) types.
 
mmm
Gonna look at it, it works with PHP yeah?
 
@HassanAlthaf well, sort of, that's the shit part - it's a great database, very promising, but the PHP driver is third-party work, it's outdated and under-maintained.
 
Aw. :P
I found a nice OODBMS.
Don't know if it works with PHP.
Just found out that when I was researching on the surface about OODBMS.
 
@HassanAlthaf I've been trying for years to put pressure on them to beef up driver support for any major web language, PHP or Node, but they're completely reliant on volunteer contributions for basically anything other than the official Java drivers.
 
Who, EyeDB?
 
10:03 AM
@HassanAlthaf no, Orient
 
I see.
 
@HassanAlthaf Eye has C++ and Java drivers only, it seems.
 
Yeah.
I use Java these days, so might try it.
 
Good for you :-D
I'm stuck with PHP.
 
Because of work?
Or personal preference?
 
10:06 AM
Work, yeah. And reluctantly personal preference - I mean, honestly, I think PHP has too many weak points to even begin to sum them up, but I haven't found a viable alternative, so I stick with it.
(and not from lack of searching ;-) )
 
Lol
I'm young, I'm free, I can decide what to use. :P
The only advantage of being young.
 
@mindplay.dk Those weak points can be mitigated by someone with the knowledge... you can write absolutely great OO code with PHP
 
@Jimbo oh, I know, don't get me wrong, I enjoy coding in PHP :-)
@Jimbo it's a very lovable shit language :-D
 
@Jimbo you're right. :P
PHP is the language which helped me to grasp various Object Oriented concepts.
 
Shhh don't say that so loud... ;-)
 
10:08 AM
@Jimbo the problem is, most developers spend 10 years writing horrible crap in PHP - it's an easy language to learn, but it's an extremely difficult language to master.
 
@mindplay.dk Yeah, it is not easy to write neat code in PHP. :/
 
@mindplay.dk It has a low barrier to entry, yet you'll still find seasoned veterans picking it up for two reasons from what I've seen: (1) You can do all the cool stuff you can in other languages in PHP and (2) It's fun. I think if you can get towards mastering it, and still having fun... you've got the best of both worlds
I mean, come on... PHP "7" is basically Java :P
 
NO!
PHP can't be compared to Java. :P
Java is the king.
I don't know whats wrong with most of the people on Udemy.
They still teach mysql_* on PHP courses.. lol
Void Types
Adds a void return type to require that a function does not return a value.
I would have been very happy to have void return types, but this RFC was another casualty of Andrea Faulds quitting as a contributor to PHP.
SHT
 
@Jimbo haha, like fuck it is ;-)
 
:D
 
10:14 AM
Was wondering..
Whats the best to have? Bachelors in IT, Computer Science or Software Engineering?
 
Depends where your interests and passions lie. Diplomas are not degrees.
 
Btw, are courses like these worth the time and price? : esoft.lk/computer-studies/other-diplomas/…
 
If PHP is inching closer to another language, it's closer to Dart, being gradually-typed... I think the biggest problem with PHP is the type-system, which is still horribly inconsistent and, worse, incomplete. With the introduction of return types and scalar type hints, we're inching closer, but we still need things like property type-hints and accessors before the type-system can be said to be "complete" by any stretch.
 
@Jimbo If I'm interested in developing softwares and stuff?
@Jimbo I know Diplomas are not degrees.
Like, I don't get the difference between BSc IT, BSc CS, BSc SE.
 
@HassanAlthaf Well, look at the contents of the courses from other universities. The problem is, you can go to some crap universities and not learn anything, so you need to choose one well known for good output
 
10:17 AM
Finance is a factor. :P Can't afford a University, I'll have to goto an institute.
 
@mindplay.dk Property typehints as in... this class member can't exist unless it's of this type?
 
Yep
 
That's what a constructor is for :-)
 
Er, no.
 
Well, you're either using a constructor or a setter to create an object in a valid state, right?
 
10:19 AM
A constructor is for hard dependencies.
Yes
You're talking about the public API of an object though. Internally, there's no guarantees, which is why we need property type hints.
 
Ah yeah, that's what I was about to say
But the public API is what can be interacted with by the end user and your private implementation is up to you... we should be programming defensively anyway.
 
@mindplay.dk Moving towards a more strongly typed approach won't solve most of your problems anyway
 
What I'm trying to say is that why should we let the compiler fail for us on something so trivial when it's our fault and we should be checking for the object type anyway (even if we did have these property type hints)
 
Also, why should you care about the internals of an object, as a consumer of its public API?
 
@MadaraUchiha properties can be public
 
10:21 AM
What if I require a DateTime object, only to internally convert it to a string of the day of the week? Who cares?
@mindplay.dk Properties should not be public.
 
@mindplay.dk We don't have c-style structs in php :P No global mutable state
 
@MadaraUchiha yeah, because they're not safe!
@MadaraUchiha there are plenty of cases where the only thing you'd be doing in an accessor is a type-check.
Should we take an example? :-)
 
'Web Application Development
Implement the knowledge gained in “Business Skills for e-Commerce” and develop your own web application using the world’s top ranked language PHP.'
lol
 
@mindplay.dk They aren't safe in any language, even those with strong typing
 
@mindplay.dk This would be good
 
10:23 AM
@mindplay.dk And there are many more cases where you do more or less than that.
I'll tell you what I tell everybody.
I program in JavaScript, Java and PHP
 
Still think it's up to the dev to unit test and code defensively - I mean, so what if they get a wrong param internally? You don't want it to fatal, do you? You should have coded for that - so you would throw a catchable exception
 
I know what it's like with strongly typed, loosely typed, and everything in between
Type errors are not the kinds of errors/bugs that keep me up at night.
And type hinting is never a replacement for unit testing anyway
JavaScript objects have all properties as public by default (with difficulty to change that too), but as a disciplined and seasoned JavaScript dev I can tell you: meh, who cares.
 
What kind of different " secure " between oop vs procedural performance?
 
Okay, let's take an example then, look here:
http://www.tehplayground.com/#QFPsO6Uer
 
10:26 AM
@VarunaLex None whatsoever.
 
And the type-hinted alternative to that:

class Person
typo
 
@mindplay.dk I want to fill in a person's age from an HTML form
Whoops, I can't. I have to cast it first.
 
er, yeah, you have to validate your input. how is that a bad thing?
 
Now, I don't mind that, but that's behavior that should be tested
It depends on the requirements
 
you should test it either way, I'm not saying it's a replacement for testing
 
10:28 AM
Do I want the object to accept strings? What do I do in that case? What if input is invalid? What if it is?
@mindplay.dk Exactly, so getting worked up over type-hinting and strong typing is pointless
You're going to test it anyway
(Right?!)
 
But look, PHP version:

class Person
{
/**
* @var int
*/
private $age;

/**
* @param int $age
*/
public function __construct($age)
{
$this->setAge($age);
}

/**
* @param int $value
*/
public function setAge($value)
{
if (!is_int($value)) {
throw new UnexpectedValueException("unexpected value for age: {$value}");
}

$this->age = $value;
}

/**
* @return int
*/
public function getAge()
{
return $this->age;
}
}

// example:

$person = new Person(30);

var_dump($person->getAge());

$person->setAge(40);
 
@mindplay.dk Paste, CTRL+K, Enter
 
ugh
class Person
{
    /**
     * @var int
     */
    private $age;

    /**
     * @param int $age
     */
    public function __construct($age)
    {
        $this->setAge($age);
    }

    /**
     * @param int $value
     */
    public function setAge($value)
    {
        if (!is_int($value)) {
            throw new UnexpectedValueException("unexpected value for age: {$value}");
        }

        $this->age = $value;
    }

    /**
     * @return int
     */
    public function getAge()
    {
 
$person = new Person(Age $age);?
^ Value Objects with their own validation ftw
 
@Jimbo You're going to box a number into a value object?
Is PHP not inefficient enough?
 
10:29 AM
I like my abstraction.
:D
 
@Jimbo Really?
 
this is only boxing if Person doesn't have any other properties, I'm trying to prove a point
 
@MadaraUchiha Nah, not really. But things like IP addresses I do
@mindplay.dk With your example, you know you can type hint for scalars soon right?
public function setAge(int $value)
 
$jimbo = new Person(new FirstName('Jimbo'), new LastName('Uchiha'), new Age(30), new Money(50, MONEY_USD), new Address(new Street('Whatever'), new HouseNumber(42)));
 
yes, that solves one side of the problem
class Person
{
    public int $age;
}
 
10:31 AM
@MadaraUchiha Just factory it and you're good (Y)
 
There, that's what it should look like.
 
@mindplay.dk Are you trolling?
;D
 
fuck no, dead serious.
functionally equivalent.
one line, one type hint.
 
I much prefer how it's done in C#
 
10:32 AM
instead of writing accessor methods and repeating type-hints all over the place. are you kidden?
 
With getters and setters having their own special syntax
And all properties private by default.
 
@mindplay.dk Don't forget, you likely will not provide setters for every property
You'll also likely want validation for these properties
 
Okay, that's still two methods and 3 type-hints too many.
 
Say, age > 0 and < 40, that is either up to the object or a validation object to handle
 
A validation object
 
10:33 AM
@Jimbo sure, I'm just demonstrating the case where it's a straight type-check and nothing else - this is extremely common in many models.
 
@mindplay.dk Models as in, entities?
 
any model, entities, view-models, data-models...
this is especially common in view-models...
since they're usually just data for consumption in a template.
 
@mindplay.dk Look, like I said, I don't mind the (optional) type-hint.
I just think that PHP has worse things to focus on
 
@mindplay.dk See, I'd like protected int $age;, still a no-go for the public for me
 
10:35 AM
(but I see your point)
 
@Jimbo yeah, but that leads to the other missing feature: accessors. If you had that, you could refactor between public $age and a pair of getters/setters, which, currently, you need two methods for.
@Jimbo so you could start with public $age, and if/when a business rule (like range) is introduced, you can refactor without breaking your public interface.
with asynchronous get_*() and set_*() methods you don't get that.
Dart code is fucking beautiful because of these two features. Writing (and reading) all this boilerplate junk code is tiresome.
C# also refactors bautifully because of those two features.
 
@mindplay.dk I'd have to go through all my codebase and look for places where I did $obj->age = 1; and change those.
No chance
Use a setter from the beginning, then I only need to make that refactor in the setter
 
PHP refactors horribly because it doesn't have these two features. So you either code defensively, using get and set methods for everything, or you put up with unsafe code using public properties.
 
@Jimbo No
That's not how accessors work
 
@Jimbo precisely my point!
 
10:40 AM
With accessors, $obj->age = 1 will call $obj->setAge(1) behind the scenes (sorta)
 
@MadaraUchiha Ohhhhhhh
So you're saying if I have a setAge() method, it'll call it?
 
@Jimbo The syntax is something like
 
Well, magic is bad... 'mmkay, just like using __get() and __set()
But I do think that's kinda nifty
 
PHP actually had accessors but internals killed it.
 
int age;
    get() { ... }
    set(age) { ... }
 
10:41 AM
killed it with fire.
sigh
tears up
 
Abe
we can't have nice things
 
yep.
for a while I used @property annotations and __get() and __set() magic to support protected "accessors" - it works nicely, you can even mix it in with traits, but it's horrible for performance.
 
Hmm new episodes of Rick n Morty
 
@RonniSkansing aw HELL yeah, I broke them out last night ;-)
 
@mindplay.dk In JavaScript, what I do is test for the cases I care about (i.e. what I document), and the rest is left as "undefined behavior, which may cause nasal demons".
 
10:45 AM
=] awesome
 
Traits.. fml. I'm out now >:P
 
The bugs I have are not type related ones.
 
@MadaraUchiha yeah, the trade-offs in PHP are similar.
 
I just don't care much about types
What I do care about, I test for, and what I don't, knock yourself out.
Can and will change without warning in the next minor version.
 
One thing I care deeply about is IDE support - things like automated refactoring is a huge time-saver, but it's not safe unless your code is comprehensible in terms of static analysis, which currently means slavically type-hinting every fucking last thing with php-doc. Which I do. And I'm happier, but, having coded in C# and Dart, I'm not happy
 
10:48 AM
@mindplay.dk It's safe when you have tests...
That's precisely my point
 
okay, it's safe then, but then it's no longer automated rafactoring, is it? you're doing half the work manually, when the IDE could have done it all in a split-second.
 
Sure it's automated
I write test code for equal or longer time in most applications
 
it's not automated unless it's guaranteed to succeed - if you have to manually fix it up afterwards, it's only partially automated.
 
It has nothing to do with the automation of refactoring
 
trivial case, rename a property.
 
10:50 AM
@mindplay.dk I do it in JavaScript all the time... JavaScript doesn't have declared types, remember?
 
the simplest refactoring you can do - it will not work if you haven't type-hinted every variable and property of that type, everywhere.
 
But it does
It depends on how you write your code
 
what? no.
 
If you use globals all around, and constantly change the value of the variable so that it changes types, you're going to have a bad time, and you have bigger problems than automatic refactoring.
 
how so?
yeah, so?
 
10:52 AM
At least Intellij/WebStorm handles refactoring of variables like a baws.
 
some of the time.
 
Same for functions, and even for variables that hold functions.
@mindplay.dk I don't recall the last time I had a problem with it.
And I refactor a lot
 
due to inference, yeah - and Storm does that for PHP as well now, to some extent.
inference doesn't always work.
 
You do have the added step of running my tests every after a major refactor
But I run my tests every 5-10 minutes, so who cares.
@mindplay.dk Who cares about inference?
Who cares about the type of the variable
Renaming a variable strictly relates to scope, and nothing else.
 
yeah, I test continuously too, but I don't like writing redundant tests for shit like the type of the Person::$age property ;-)
no, I'm talking about renaming a property
of course local vars rename witout incident.
 
10:54 AM
@mindplay.dk In JavaScript, the two are pretty much the same...
 
in pretty much any language for that matter.
 
Different syntax, same concept
 
yeah JS is not PHP, which is what I was talking about actually :-)
 
@mindplay.dk Eh? I don't explicitly test for Person::$age to be an int, I test that when I enter 50, I can do $person->getBirthYear() and get the expected result
If I care about a string, I'd pass a string and check for the same output
And the rest can go to hell, you want to pass a boolean? Fine by me. Something unexpected would happen, sux2bu
It's undefined behavior, behavior I don't care about.
 
@MadaraUchiha but you're again assuming a more complex case than the one I quoted. In my example, $age has no business rules, just asynchronous getters/setters, so that is all you have to test. Which is completely redundant and could be done in C# or Dart with just public int $age.
 
10:57 AM
@mindplay.dk That's fine and dandy, but the entire point of testing is to poke an object and assert output
The $age property plays a role of some sort, otherwise it would not exist on the object to begin with
That is what you test.
 
when the only rule is a type-check, in languages with property type-hints, you don't need a test.
 
The getter/setter test is almost always implied
You don't test for getters/setters directly, unless they do some real work.
 
yeah, but that's the trade-off I'm not happy with: for trivial properties, where the only business rule is a type guard, I can choose between unsafe code, writing a lot of redundant tests, or writing a ton of boilerplate. Those are my choices.
 
Abe
@MadaraUchiha @MadaraUchiha now imagine this in the hands of Billy Silly javascript newbie that doesn't give a shit about being meticulous :D
 
@Abe Nasal demons
 

« first day (1751 days earlier)      last day (3197 days later) »