« first day (2728 days earlier)      last day (2445 days later) » 

17:00
That said @Jimbo I think domain and infrastructure make a lot of sense.
Let the refactor commence.
@abr Actually a friend of mine once said never say no to an interview. And that is why I went for the interview, I wasn't looking for a job, I was just contacted. And now that I have cleared all the interviews, I am of course thinking about it. nothing wrong with that.
abr
abr
You have a wise friend @mega6382
I'd say, trace the objective of why you're thinking about it. If it's money, experience, knowledge, connections, better prospects, if it's a limited time for both companies, then follow your gut
some things are more important than money
@mega6382 don't think you won't have to deal with stupid legacy code on in-house products either.. only difference is depending how long you're there it might just be your stupid legacy code
@PaulCrovella true dat. But for an in-house product there is just 1 code. But at an outsourcing there is all kind of shit.
"for an in-house product there is just 1 code" - oh my sweet summer child
5
17:08
:P
@abr yeah, I am gonna talk to that friend as soon as he gets free from his work.
Hallo room
Jay
Jay
any thoughts on this? pastebin.com/hwfaph5T
@abr read in a couple articles that the reason an employee leaves a job is because of difficulties with management/colleagues, more often than for money
ok, I'm home at last
so, @Shafizadeh, you said you had a problem
17:23
@tereško more that a problem .. I understand I even don't know what I want !!
can I explain it now?
sure
@tereško I want to make a short list of recent user's notifications
like when you click on your inbox button which is in the header of SO site (on the top-right) and a popup opens
so do you know what I want to do now?
@Jay I don't even get the pattern.
Jay
Jay
the first array is a list of times
the second one is them combined into 10 minute durations
@Jay That made no sense. What is the point of this? What are you trying to do?
17:27
@Shafizadeh before you begin, there is one thing: you should not track each notification separately for whether it has been viewed. Instead you should store the timestamp of when user last checked the notifications
Jay
Jay
its the times
that will simplify a lot of things - that's how SO does it, that's how twitter does it, that's how skype does it too
Jay
Jay
09:00, 09:05, 09:10 etc... It will just combine a new array with the start and end time based on the 10 minute duration
@Jay I gathered that they are time stamps, yeah.
abr
abr
@Tiffany I believe that, I've switched jobs once for a lower salary and a smaller campany because of the work envoironment. Not because of any issues but because I felt I could learn more, gain more experience, and because of the people Who I work with
17:29
@tereško well I have a column named "seen" in the notifications table which will be 1 (for all unread notification) when user open his inbox, should I change the algorithm
?
@Shafizadeh you probably should. Because you already have tried to implement that same behavior.
@Shafizadeh also, another thing: you will be showing some kind of numeric indication of the amount of the unread messages. It means that, when user clicks on the "show notifications", you already know, how many unread notification messages there will be. So, you can pass that number in the request as a parameter. That way you will already know, whether "all unread messages" fit in your "default limit".
Or do you need to do a different query, without a limit, which only has the "larger than last-seen timestamp"
so ... does that cover it :D
AllowOverride All recommended in documentation. – #76189
Sorry I disconnected ..
ok, my current detecting read and unread notification works well. And yes, the behavior is the same .. let me don't touch it now :P
I select notifications in two steps:
1. I select the ids (according to some rules). I don't do any grouping here, I just select the id of latest (almost) 15 notification
Noted that, notifications have different types .. some of them are message (being ping in the comments), some of them are answer (for user's question), some of them are votes
Again, in the first step, I just select (lets say) 15 last notifications .. without grouping
And in the second step
2. I get details of those ids, plus I do a grouping in this step. Grouping mean, I sum (merge) the score of the ones that are related to the same post.
So probably the first query give me 15 ids, and all of those be of "vote" type and belong to the same post, so the second query will generate just one summed notification
See? activate users (who earn lots of votes in a short time) will see just one notification into their inbox list. Any idea? @tereško
17:58
@Shafizadeh why do you want to do the grouping on the backend ?
that seems purely like a frontend thing
and then you will have the option to have the "expand" without making another request to the backend
besides, what would be the point of making the "points" as part of notifications?
I don't have "see more" option
ah, sounds like you do not have android phone
@tereško I'm following what SO does .. take a look at your notifications on SO
yeees
@tereško I use iPhone 6S
18:01
point and notifications are separate
with "notifications" I mean the "inbox"
right, that's the only different :P
that is a major difference
we keep them all in the same list
and at some point you will (maybe) get "senior users" who have been on the site for years
those people will be getting ... emm ... ambient points
@tereško yeah, and I'm regret of doing so, but no time to do any change in the product, we have determined a launch-date, we have get some money for our go-to-market-plans of our sponser .. we just try to finish it
18:04
what do you mean?
separating those takes like two hours
@tereško I mean I cannot make inbox and points separate
@tereško what? not really
@tereško also, what you mean by this? We just select the recent notifications
yes
and "senior users" will be getting "you got 5 more points" notification every hour
it would make that feature into an annoyance
exactly .. that's the problem ..
my current algorithm shows just 1 notification for seniors (who are active)
grouping does not solve it
@tereško look, I have another page which list all user's notifications from the beginning until now
but now, I'm talking about that popup
so I want to group the ones that have score, like SO
18:07
then that is a completely separate query
correct
then there is no problem
you have two separate queries
:-)
@tereško yes I have
one for unread message and one for point-per-question
and stop using UNION
lemme think about it
18:09
and if you need to sort them, do it in the frontend
@tereško why?
In the first step, I need to get ids, just ids
the AJAX response will be containing two different collections anyway: messages need content, author and time; points need sum and question
why do I need two different queries for ids?
no
you do not make a query just to get IDs
you get the data that you actually need
and do NOT store reputation increase and messages in the same table
what you're saying is like a huge modification
18:12
which part?
I guess my current algorithm needs a small modification
wait
if you have been storing them in the same table, then it is not a "huge modification" but a "huge mistake"
also, from the pile of "huge mistakes": don't use sha2 to store password hashes
@tereško I have a table for all messages, another table for votes, another table for comments etc .. also, I have a table names "notification", which will be filled using a trigger on all those other tables
@tereško I read somewhere it is the safest hash algorithm, isn't it?
no
it is not
so what hash algorithm is your suggestion?
ok thx, I'll take look at it
since version 5.5 php has dedicated functions for dealing with passwords: secure.php.net/manual/en/ref.password.php
ah good, ok :-)
the underlaying algorithm is "bcrypt", if you are curious
So, I have a table named notifications, which contains all notifications, it has a column named "type", "1" means "vote", "2" means accepted answer, "3" means comment etc ..
18:20
that was a terrible idea :D
@tereško good to know
@tereško but works well :-)
what you have there is an "activity log"
and problem with it is that you cant actually use it for anything else
interesting, because the name of it is "events" in reality :P (I called it "notification" for you to make it more clear)
it's an EAV table (which is considered an antipattern in SQL)
@tereško please don't make me disppointed :-(
18:25
there are other things too ... but they will just make you sadder
ok, I prefer to be faced only with my current problem :P
here is something, that you might have missed: the "latest points" is not a critical feature
You know, I will refactor the whole project when I launch it
you could have added that feature after the release
if you have a separate "reputation page", then the worst thing that could have happened would be people constantly refreshing it
@tereško yes, my current notification system works as well for non-busy users .. it just have a small problem for busy users
@tereško do you mean it would be a complex query and use my server hardware too much?
18:30
no, it would just mean, that your users would be sitting in that page, instead of "producing content"
my advice would be: make the "new comment", "new answer" part work
add the reputation-part later
your users can't track those by themselves, but they can track the reputation
well I don't understand your point ... why should user sit on reputation page?
Noun: self-aggrandizement
  1. Behavior which increases one's own wealth or power, or which is intended to create an appearance of importance.
  2. 1906, Anna Katharine Green, The Chief Legatee, ch. 29:
  3. [W]hat can selfish greed, what can self-aggrandizement and the most pitiless ambition effect against men who own to such discipline as this?
  4. 1907, Jack London, "A Day's Lodging" in The Love of Life and Other Stories:
  5. "In your case, I fear, confession is exploitation by indirection, profit-making by ruse, self-aggrandizement at the expense of God."
(2 more not shown…)
@tereško they are working now .. also reputation part is working too .. what's the point?
then it's not a problem
if the information about point does not work well with "notification widget" then you remove the point from it
you can add them later
Ah I see .. ok :-)
18:36
and maybe your users won't actually care about it - when you launch, you will be able to see the behavior
@tereško they care about money
is the money tied to the points?
if yes, then it definitely should be in a separate widget
my website has a money plan except reputation
@tereško they are totally separated ...
then it's not a problem
but the solution stands
anyway, currently, my internet is shit, I will ping you later and explain my problem by mentioning to the code base on bitbuched later @tereško
18:40
sure
... and now I'll have a cold beer
thank you so much
also as a good news, by now, 10 schools and 54 teachers will use our website for answering-students-questions-and-get-money-instead ...! I will give you 1% of our income (in future) when our income got more than 10,000$ per month
19:18
hi all
19:34
@Shafizadeh I am not so sure if that such a good idea :D
I will have to answer some interesting questions about "so .. someone in Iran is just sending you money?"
I think I need another beer now
ThW
ThW
lol
19:56
@tereško Oh ye' of many articles...do you have any that will teach me how, when and where to use exceptions?
@Allenph I don't remember any articles about it (well .. there was one about naming of exceptions, but that's not what you want)
I tend to use them, when I need information about an error state to cross the layer
hi @all, anyone having experience with PHP websockets?
@tereško I could use that as well.
What about errors between layers?
what do you mean by "between"?
What if there are multiple errors? Should all validation errors be thrown separately or as a single unit?
@tereško Like between a mapper and a repository for instance.
Or between two entities.
ThW
ThW
20:04
@Allenph here is no between, an exception can only happen with a call, each call on the stack is a layer
@ThW He said he uses exceptions to move errors between layers.
if there is an error in a mapper, it throws an exceptions that is always caught in the layer above
What I was asking is what you do when you have an error that should stay between two objects in the same layer.
is the repository (which is in that layer) does not know how to handle it, it throws a different exception (adding the previous one in the stack)
@tereško Is there not an instance where another object in the same layer might want to handle the error?
20:05
repo and mapper are not in the same layer
@tereško Both infrastructure, are they not?
are mappers using repositories?
ThW
ThW
@Allenph that is unknown and this unknown is one of the reasons to use exceptions
you might not have a separate name for them, but they still are in two different layers
@tereško Seems like you're considering a layer a type and the support objects for that type.
20:08
no, I am separating them by responsibility and hierarchy
So everything should either return a type, or perhaps null and otherwise it should throw an exception.
depends on how anal you want to be about it
in a best case scenario there would be no "or null" option .. well .. not in your architect at least
ThW
ThW
@Allenph yes (at least until you learned enough to know when you should not use that approach) :-)
Man, that's such a foreign concept to me.
@tereško Why do you say that? It's normal for a mapper to return Something or nothing.
it returns something or there was a problem
as I see it, only things that are at the "leaves of object tree" should have an option to return null
like "get last visit" can return a null, because it is at the leaf of an object graph/tree
in your case the data mapper is not a leaf
.. hell, it is in mine, but I still see returning a null as a "lazy move"
20:16
You should throw an exception even when it's something normal and expected like that?
but it is not normal
your code expected an object
if you do not throw there, you will need to do a null-check .... aaaand ... that will be somewhere
What is the benefit of using exceptions?
Instead of checking the return value?
no null-checks
You're still checking for null. Or for validation errors. Just in a different way. A way that seems more complicated.
consider these who pieces of code:
$user = $mapper->fetchById($id);
if ($user == null) {
   ...
}
and
try {
    $user = $mapper->fetchById($id);
} catch (UserNotFound $e) {
    ....
}
which is more precise and communicates the intent better?
20:21
Definitely the second one. But what about a case where there is more than one possible type of exception?
@tereško Exceptions shouldn't be used for expected outcomes, like not finding a user in storage.
^ See. There seems to be a divide here.
try {
    $mapper->update($user);
} catch (UserNotFound $e) {
    ....
} catch (EmailDuplicate $e) {
    ...
}
Some people say that, and others say what @tereško is saying.
@tereško I see. It looks exactly the same as handling errors the normal way, you just use typed errors rather than like some crazy associative array or something.
@Trowski but it is not an "expected outcome". To reach that branch someone needs to fuck up.
either using an outdated link or actively "poking" at the page
20:25
@tereško If your API provides a $mapper->exists($id) method, then perhaps.
Consider a user logging in, the code shouldn't need to catch a UserNotFound exception because the email address is wrong.
That's not exceptional.
email not being found would be exceptional
password not matching would not
@tereško And what do you do in that case?
depends on the architecture
I would actually throw an exception too (but from a service layer), because I would want to handle it with a different controller's method
@Trowski?
also digging a bit after that, first time I see en.wikipedia.org/wiki/Therac-25
20:47
Hello everyone! I just trying my luck - is there someone that knows how to work with vBulletin and in general - designing forums, I would like to talk with him in private. Looking for some basic nobbie steps :)
@Allenph, So them, didn't quite help me :/
@kicklog You need to ask a more specific question. Have you even tried? Have you Googled? Have you really watched the videos?
@Allenph I have different methods for looking up users on the mapper, and null indicates it was not found.
In the password case, the mapper just returns the user object and the password is verified by the user object, not the mapper.
There's pros and cons to either architecture, pick what suites you.
this is why I don't have my mappers returning objects
too many complications
21:00
@tereško Right, mappers can return arrays, that's often more appropriate.
nope, mine return boolean :D
I pass in the instance, that should be populated/stored
@Trowski That seems strange to me. Why pull the object out of persistence when you could just leverage SQL to see if the hash/username combo is there?
https://gist.github.com/NickCraver/c9458f2e007e9df2bdf03f8a02af1d13 in case you want to add them to your routes
@tereško This is also seems strange. Seems like you would have to do some kind of validation over and over again in services or once in a weird place like the mapper.
21:03
@Allenph because you do not know the salt
@Allenph If SQL supports your hashing scheme.
@tereško You store the salt separately?
Oh doi. I'm being an idiot. Nevermind.
@tereško I was referring to the fetch methods, obviously those have to return an object or array.
@Allenph secure.php.net/manual/en/book.password.php .. yes, you are being an idiot
Yeah, yeah Teresko I was being dumb.
Wes
Wes
21:05
evening tho
@Trowski yeees, I pass in the fetch method an object, that I expect to be populated
stackoverflow.com/a/11467138/1329850 This still recommended? Extending exceptions?
o/
ThW
ThW
Yes, throw and catch specific exceptions, do not try to parse/match the exception message to identify the error. (yes I have seen that)
@ThW I wasn't going to attempt that. It's just the entire time I've been in here everyone has basically told me to never extend anything.
@tereško Ah. I usually go with the ClassName::fromArray($mapperResult) strategy.
21:08
Seems like you should use a common interface, not inheritance.
@Trowski no
ThW
ThW
Exceptions can implement interfaces, and you can catch the interfaces
$thing = new Thing($id);
$mapper->fetch($thing);
@ThW That's why I asked if you should extend or not. Common interface is better than extending, no?
^ this is what I do, @Trowski
21:09
@tereško So then your object has to have tons of set methods, not sure if I'm a fan of that either.
The only problem I see with that is implementing a bajillion interface on the lower levels of your exception tree.
@Trowski You don't use setters and getters by default?
Oh also let me send you my address for those stickers.
@Allenph Getters yes, but setters only on fields that can be updated.
ThW
ThW
@Allenph you will still need the logic implemented in the Exception class
@Trowski every approach has its tradeoffs, but I can create setters so that the changes are more .. emm .. atomic. And also There are benefits, like being able to use multiple data source to populate/persist the same entity
@Trowski Yeah. That's what I do too.
21:11
@tereško Right. I can use multiple data sources for the array too, i.e. the database or redis.
@tereško I do that without doing what you're doing.
Typically I shove the database result row in cache and the mapper looks there first before going to the database.
@ThW Well all of them would extend Exception or one of the other SPL exception types, but should you extend your custom exceptions?
@Trowski don't you end up with complicated constructors or magic applyData(array $data) methods ?
SpecificException inherits from LessSpecifcException inherits from SPLException

vs.

SpecificException inherits from SPLException implements LessSpecificExceptionInterface
LessSpecificException inherits from SPLException implements LessSpecificExceptionInterface
21:14
why would you need an interface for an exception :D
@tereško So you can catch by a coarser type.
ThW
ThW
group exceptions
hmm .. true
but that would be the point when your code has too many exceptions :D
You just told me to only use exceptions 5 minutes ago.
And for them to be specific.
I was talking about a specific case
21:16
Head Explodes
@tereško The static constructors can be longer, yes. No magic apply data methods though.
Wes
Wes
don't do
BException extends AException
CException extends BException
etc
always inherit from Exception (most likely) or Error (rarely)
@Trowski that sounds like somewhat hard to unit test :D
@Wes When I Googled I found this.
s/hard/annoying
21:18
@tereško Not really, just verify the state is as expected after calling the constructor.
Yeah...how are named constructors hard to test?
@Allenph the example like UserNotFound can probably be replaced with EntityNotFound, because you will know what you were mapping
@Allenph IMO they aren't more difficult than regular constructors.
and other exceptions too can be reused
there would not be so many of them in the end
@Trowski Especially considering usually most properties have typed setters.
Wes
Wes
21:21
caniuse.com/#feat=css-matches-pseudo reminder that the css world is still miserable
@Ekin another example - bug in a markup language parser causing some entities to be dropped... doesn't seem too bad until that parser is used in document conversion... for medical journals... where some of those entities were mathematical symbols. As far as I know nobody died from it, but that was a frightening thing to catch after a few tens of thousands of articles had been processed.
21:32
I feel dirty
4
eww... @pmmaga has cooties
hahaha :P
that came about because I wanted to check their unit test coverage
which wouldn't actually run because of that
it's kind of what I expected
Do you guys test your named exception constructors?
Wes
Wes
21:50
lol
you don't test that
you test where the exception is thrown
Good point.
So what do you do when you have multiple errors? Like a username already exists AND a the password isn't more than 8 characters long or whatever?
Because it seems like the only option would be a generic ValidationError exception which contains a collection of ValidationError objects or something.
@tereško IE this seems like ^ that would be that class I wrote which you scoffed at.
Wes
Wes
i have sort of a collection of exceptions
for example the constructor of my domain objects throws an exception that contains potentially multiple exceptions description
Do you have an example?
And it seems like you should always throw that collection even if there's only one validation error, yes?

« first day (2728 days earlier)      last day (2445 days later) »