« first day (1493 days earlier)      last day (3455 days later) » 

3:03 PM
lol @feeds
ow wrong room :|
 
posted on November 17, 2014 by kbironneau

/* by Twinsen */

5
 
3:24 PM
I'd happily kill that idiot who decided to put entire business logic in stored procedures.
 
@Leri I fail your pain brotha
 
@Leri b-b-but
38
Q: What are the arguments against or for putting application logic in the database layer?

Phil LelloNOTE The audience of programmers.se and dba.se is different, and will have different viewpoints, so in this instance I think it's valid to duplicate What are the arguments against or for putting application logic in the database layer? on programmers.se. I couldn't find discussion on dba on this...

 
@Leri What's wrong with that?
 
Comparing the answers here and on SO, the gap is striking. The developers protest at the delays entailed from centralizing processes in the database, but to the DBAs that's a good thing. Forcing people to put more time and effort into requesting a new view or sproc reduces the number of contact points with the data, making it easier to maintain consistency and reducing the number of points of optimization. — Jon of All Trades Apr 10 '12 at 21:35
 
Especially if you're using a good database like PostgreSQL, you really should put your business logic in the DB.
 
3:34 PM
@AndreaFaulds It's horrible practice and basically tells the next person to inherit the project after you to go fuck him/herself
:)
 
The database shouldn't be a dumb data store, then it might as well be a JSON file. The database enforces a consistent dataset.
@PeeHaa How so?
 
@AndreaFaulds Impossible to debug and maintain
 
@PeeHaa Huh?
 
That's a significant reason, gotta be honest
Oh look, I'm not getting exactly the data I see in terminal back from the calls throughout the codebase. Why is that?
Although, they could read the query... so that's the flip side
 
21
A: What are the arguments against or for putting application logic in the database layer?

Phil LelloI'm moving my old answer across unedited from programmers.se, as answers seem pretty polarised between sites. I know I'm in for a world of hurt here, but put business logic in the database because: You can allow business power users direct access to the database and not worry ab...

testing matters is a wrong reason...
it's ok to not know the tools, it's not ok to dismiss an entire way to work because you don't want to know them
3
 
3:36 PM
They asked that on the DBA forums
They should ask it on programmer forums
 
they have :)
3 mins ago, by Florian Margaine
Comparing the answers here and on SO, the gap is striking. The developers protest at the delays entailed from centralizing processes in the database, but to the DBAs that's a good thing. Forcing people to put more time and effort into requesting a new view or sproc reduces the number of contact points with the data, making it easier to maintain consistency and reducing the number of points of optimization. — Jon of All Trades Apr 10 '12 at 21:35
the programmers.SE question:
44
Q: What are the arguments against or for putting application logic in the database layer?

VetleMost software developers want to keep application logic in the application layer, and it probably feels natural for us to keep it here. Database developers seem to want to put application logic in the database layer, as triggers and stored procedures. Personally I would prefer to keep as much as...

 
There you go
Version control, testability, and stored procedures.
One of those doesn't belong in that sentence.
 
Er, you can do all three at once.
 
Plus involving a DBA for a code release?
Necessary?
££££
 
3:39 PM
I'll admit freely that I don't use stored procedures, though. That's because I don't use Postgres. I probably should step into the light, but I'm lazy and use SQLite3 for EVERYTHING
 
@AndreaFaulds I've cleaned up the covariance checking code: github.com/morrisonlevi/php-src/commit/…
It should be easy to switch to invariance now.
(If that's what we choose)
 
@LeviMorrison Those code comments. Me do likey.
 
In case of threatening of hacking a website for a large company by hacker organizations. Will the dev team get blamed?
 
Picture-sharing site? SQLite3. Social network? SQLite3. Blog? OK, I actually wrote that one to use flat-file Markdown.
 
( just red a message about something that happend here in my country where they have to chose to pay a large amount of money or they will publish the data.)
 
@AndreaFaulds I think it needs more tests (I think I see a bug) but it is cleaner than what was there (and fixed at least one bug)
 
@AndreaFaulds Huh? You have not tested business logic, is not that enough reasoning?
I can't change anything because I have no idea if it breaks anything.
 
@Leri What? Why can't you do tests on stored procedures?
I don't see any reason you couldn't unit test them.
 
If you had a page which contained a download link for a file but the file was no longer available would you use 404 for that page?
 
Also that forces me to write pretty coupled code.
 
3:44 PM
@Leri Not at all, it uncouples your front-end from the back-end's inner workings.
 
@Fabien 410 iirc... let me check
yeah, 410
 
@AndreaFaulds Here's a thing that database thing is huge. There's a stored procedures that create temporary table, nested views, etc. If I start writing unit-tests for them I will never finish the project. :-)
 
410 Gone
Indicates that the resource requested is no longer available and will not be available again. This should be used when a resource has been intentionally removed and the resource should be purged. Upon receiving a 410 status code, the client should not request the resource again in the future.
@Leri same as if the app code was awful...
 
@Leri So, what you're saying is you're not currently unit testing your business logic.
 
@FlorianMargaine Makes sense thanks.
 
3:47 PM
@AndreaFaulds But couples my back-end to that database. And my code is supposed to be flexible enough to change database later. I am unable to do so because of this shitty db.
@AndreaFaulds I am not testing business logic in database which clearly is not mine.
 
@Leri your code is supposed to be flexible enough to change database later?
 
@Leri >flexible enough to change database later
 
@FlorianMargaine that solves all my "should DELETE cause a 404" questions
 
ahahahahahahahahaha
 
that's an unusual requirement
 
3:48 PM
Oh man, really? Are you using standard SQL99 then?
 
@Ocramius :)
 
Or are you relying on MySQL-only/SQLite3-only/MSSQL-only/Postgres-only/Oracle-only/... extensions like everyone else?
Which will break if you switch database?
 
@Ocramius DELETE itself shouldn't cause a 410 though... a 4* means that something went wrong, as in your DELETE wasn't successful
 
@Leri Er, but your business logic is currently in your app in the form of SQL queries, and if you're not testing that... I don't get it.
 
@FlorianMargaine Well, it should probably be something like 202
 
3:50 PM
I use Doctrine. That's flexible enough to change DB with a single yaml string change
 
@Ocramius 204
 
The code written behind it wouldn't be affected
 
204 No Content
The server successfully processed the request, but is not returning any content. Usually used as a response to a successful delete request.
 
I really should print them all out and read them again -.-
including teapot.
 
3:51 PM
I'd like a 418 t-shirt, whose buying it me :D
 
417?
ah, no, 418
damn
so close
> This code was defined in 1998 as one of the traditional IETF April Fools' jokes, in RFC 2324, Hyper Text Coffee Pot Control Protocol, and is not expected to be implemented by actual HTTP servers.
I'm pretty sure all the servers implement it :D
 
@FlorianMargaine Yes.
 
5 mins ago, by Florian Margaine
that's an unusual requirement
 
@AndreaFaulds I don't really know how to test it at the moment.
 
but then, go on
 
3:54 PM
@Leri integration testing. You can't really unit-test SQL
Also sounds like legacy code. You don't unit-test legacy code
 
also, you could export the SP in .sql files to start off
 
@FlorianMargaine Not really. This application is 20 years old and we're replacing it step-by-step. First step is to remove old Delphi administration stuff (doing right now), then eliminate web interface that is rendered to user and after that remove this crap reusing new code.
 
it'd allow you to at least version control them, and eventually replace them one-by-one
 
I might be in charge of starting our whole codebase again, using symfony 2 and best practices... if I hang around for a while
:-|
hundreds of thousands of lines of code
 
@Jimbo I'd rather want to hear domain-driven and then eventually plug in some FW :P
 
3:56 PM
@Ocramius Hmm, we'd use doctrine, does that make you happy?
 
That doesn't mean much to me
it's just a tool.
 
:O
You're just a tool.
You contribute to it!
 
@Jimbo well... start refactoring it so that you'll be able to get back most of the components by adding them to composer.json
 
@Jimbo yes, that doesn't make me succub
 
Well, Doctrine really is just a tool.
 
3:57 PM
@FlorianMargaine Previous devs have come, implemented stuff with no comments, procedural code in classes, no specs, so no reasons why... A lot of it nobody knows why it's there or what it does
 
@Ocramius Good point.
:P
 
@Jimbo hence the "start refactoring it" :D
 
Refactoring is not really feasible with the technical debt here....
 
oh dear
I've refactored horrible horrible horrible codebases
there's always a way
:P
 
@FlorianMargaine When there's a will, there's a way. But when I'm promised a clean slate, I can't really say no... :P
 
3:59 PM
heh
 
The biggest struggle is understanding what it should do (not what it does)
If you don't have documentation that clearly identifies how the stuff should work (probably with flow charts) then it sucks.
 
We have BAs now
I think everything will be done the right way going forward, hopefully
 
@LeviMorrison yeah, it's usually what we need specs/POs for
(product owners)
I always forget about the -j option of make...
feels so good when I don't
uh
how do I use get_debug_info in C?
 
4:24 PM
@FlorianMargaine Have you met -j -l yet?
 
hm.. no
hm.. I don't see how it's useful
 
make -j -l 16 <- launch jobs until load level reaches 16
make -j 16 <- launch 16 jobs
 
oh... cool
 
The first plays nicer when there are other jobs running.
 
which value do you usually use?
 
4:27 PM
It also plays nicer when you are I/O bound (if you are building something on a network-mounted device, perhaps)
My boss prefers nice make -j 16
 
Yes, that's the one.
nice make -j 16 # launch 16 jobs with lower priority than default
 
	printf("%s\n", Z_OBJDEBUG(***args, temp));
hm, this doesn't seem to work
any help?
:D
well.. I can understand why printf'ing a HashTable doesn't work...
 
4:43 PM
TIL: 3v4l.org/ZUImE and 3v4l.org/8sjbc are not the same. #php
 
@LeviMorrison nice
 
>The author, he. Author is a male word, therefore when referencing to it you use he...
I... what?
 
Room 11,
How do we feel about removing PHP 4 constructors in PHP 7 altogether?
13
This would mean:
 
user1804599
4:58 PM
@AndreaFaulds English has no grammatical gender.
 
@rightføld Yes, exactly.
 
class Filter {
    function filter($a) {} // <- not a constructor anymore
}
Note that in namespaced classes this is already the case.
namespace NS;
class Filter {
    function filter($a) {} // <- not a constructor (since PHP 5.3.2?)
}
 
@Fabien SQUEEEE
 
user1804599
lolwat is that a ctor
 
user1804599
TIL
 
user1804599
4:59 PM
Removing such behaviour is good idea.
 
user1804599
TOOWTDI is good.
 
@Ocramius I hope they release it soon. Just gimme a version 1 :(
 
I still have to try my LEAP with the DK2
I didn't use my oculus at all in the last month and a half
 
http://thecodinglove.com/post/102882346461
The coding love
Clients...
kbironneau
1416243695
 
5:05 PM
@LeviMorrison +1
 
user895378
@LeviMorrison +1
 
anyone got an idea why this for loop segfaults? pastie.margaine.com/b0f82b71-0b8a-4c16-acd1-cf07559b4392
(if I remove the body of the loop, it still segfaults)
 
Also note that defining a PHP 5+ constructor before the named one makes the named constructor become a normal method:
 
(if I remove the for, it stops segfaulting
 
0
Q: How to insert a new line in an excel sheet cell using PHP?

PHPLoverI'm using a ready made class called "ExcelWriter" to write data from PHP to excel sheet. For this I'm creating object of class ExcelWriter and calling it's methods to do the operations using PHP. Till here everything is working fine for me. All the code is doing it's job well. The only issue is...

 
5:15 PM
class Filter {
    function __construct() {}
    function filter($a) {} // <- not a constructor (Since PHP 5.3.2?)
}
 
@FlorianMargaine I think you're using the wrong test to keep going:
 
Uhm...
<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 is needed'); ?>
 
I need help guys with this question.. Any suggestions? stackoverflow.com/questions/26924216/…. Stuck for over weekend now. Help is greatly appreciated.
 
5:37 PM
@AjGauravdeep apache or nginx?
 
i'm having a php array, and another object, i want to enclose both in json object
 
@FlorianMargaine Apache
 
i want to enclose them both as siblings in that big json object
I want this to be my output: { myobject, [myarray] }
 
Does anyone know if PHP-FPM's stderr logger is asynchronous?
or if its handled by its own worker thread at all?
 
Morning.
 
user895378
5:44 PM
@Rican7 no clue.
 
would json_decode work at this instance?
 
I take for granted how good the PHP DateTime object is until I have to work with the Date object in javascript. It is literally the worst. THE WORST!
 
Good morning everyone.. If anyone has any answers for this, please let me know stackoverflow.com/questions/26924216/…. I will try the fix right away and mark it solved if it works....
 
yea, I've been trying to read the code, and I can't quite tell if it is
 
so, what have I missed?
@ChrisBaker I actually find if annoying that in PHP the datetime objects are immutable
it causes way too many WTF-moments
 
5:47 PM
@Rican7 I can't imagine that it would be. It's just writing to stderr which is not asynchronous by default in C. Why do you care though?
 
♥♡❤ PostgreSQL ❤♡♥
6
 
@Danack the PHP processes write to stderr with error_log defaults, but FPM writes to a file by default
I'm trying to figure out if that file writing is async based on a buffer of the stderr outputs of the processes or not
 
Why do you care though?
 
@tereško I'll agree with that, but still less frustrating that the API for Date(). (inst.getUTCHours() > 12 ? inst.getUTCHours() - 12 : inst.getUTCHours()) + inst.getUTCMinutes() + (inst.getUTCHours() >= 12 ? 'pm' : 'am') -- seriously?
 
I'm curious of the potential performance concerns with a lot of logging in a production env
 
5:50 PM
Pfft, that mess was wrong as hell, lol
 
does anyone know how to add an object and array to a big json? Here's my desired output: {myobject, [myarray]}
 
that is an invalid object notation there, @JoeSaad
 
@JoeSaad You could have [myObject, [myArray]], but otherwise you need keys in there
var out = []; out.push(myArray); out.push(myObject);`
 
@tereško this is what the i got to have the pagination working..
 
wrong
 
5:54 PM
 
@Rican7 If you mean logging in general then yes, performance is an issue. A lot of people use redis (or similar) to have very fast writes on logging, and then have a separate task to fetch the log data and write it to disk. If you mean does PHP-FPM having errors cause a slow down......then the thing to worry about there is having a high error rate.
 
.. and that told us nothing
 
no!, i don't want them both to be in an array
 
Nah, the section he is referring to shows an example, and he was describing the problem wrong.
 
@JoeSaad array: [value, value1] .. object: {key: value, key1: value1}
 
5:55 PM
i want my json to have both {count_of_records: 23044, [array of records]}
 
var out = {"Count":count, "Items": myObject} -- that's what the example says
@JoeSaad What we're telling you is that the outer curly brace means there are KEYS
 
@ChrisBaker correct, that's what i want
 
So you just make it. Like that code I just showed.
 
@ChrisBaker correct
 
@JoeSaad not , this was what you asked for
> {count_of_records: 23044, [array of records]}
whic is NOT possible
 
5:57 PM
@Rican7 It is not
 
@JoeSaad {count_of_records: 23044, items: [array of records]} -- notice the difference? The key "Items" has to be there. Just like the example says. It also says the count has to have the key of "Count", not "count_of_items"
 
yes, I am sorry
i forgot the Items key
 
@DaveRandom its synchronous? so error_log will commit to a file immediately?
 
would count vs. count_of_items make a difference?
and how can i achieve that in php?
 
@JoeSaad The script looks for a specific key in the JSON object. If it wants "Count", it won't look at "count_of_items".
 
6:00 PM
@Rican7 Oh wait I may have misread something, 1 sec
 
@ChrisBaker yes, i'm not looking for what the javascript can do now.. i just want to achieve the same output in php
 
@JoeSaad As for how to make it in PHP, make a regular array $arr['Count'] = count($myArray); $arr['Items'] = $myArray;, then use json_encode on it.
 
visited 1649 days, 1646 consecutive
And the streak continues...
 
Joe.... I do not misunderstand anything here. Start from that point of view, please.
 
Stop misusing crawlers!
Crawlers have feelings too :-(
 
6:03 PM
Thoughts on removing PHP 4 constructors? @NikiC @ircmaxell @bwoebi
 
Jesus this code is horrible
not sure why I'm surprised
 
user895378
@Rican7 Yes. Logging blindly in production is a big concern. Like @Danack said, though, errors will make your program slow in any environment. The problem is the errors, though, not the logging of those errors. Focus on the source.
 
@DaveRandom the FPM code?
haha
@rdlowrey yea, well the reason I'm asking it that I was thinking about logging some info for every request, regardless of error
and before I commit to a new part of the architecture by using some async service or redis proxy, I was curious to see the effect that it would have with the default FPM setup
 
@ChrisBaker this works like a charm, thanks a lot !!!
 
@LeviMorrison Kill with fire, IMO. Been a long time since I've seen anyone using that.
 
user895378
6:07 PM
@LeviMorrison Down with configuration! Up with convention!
 
@Rican7 I think it's handled by the master process, so it wouldn't block an individual request but could prevent fpm from handling new requests. But the whole think is almost completely illegible so I'm not confident any more.
In short, I don't know, because fpm is insane
 
lololol
aww, well thanks for the help
 
@Rican7 I've got an old system transitioning into a new one, and I'm logging every incidence where the new one bootstaps the old to use some functionality that has not been ported yet. It does not seem to have an adverse effect on performance or server load.
 
I really appreciate it
 
I might have another read later
 
6:11 PM
@ChrisBaker thanks! that's helpful
 
I would like to understand fpm properly so I can improve it instead of jst complaining about it all the time
 
@ircmaxell wow.. [= that is almost 5 years consecutive
 
@DaveRandom This is one of the few times when I recommend re-writing something from scratch. Any changes are probably going to break things/expose already broken things. So long as the ini files stay the same (or possibly allow longer lines ;) then it would be easy to get people using a new version.
 
@Danack I'd rather provide a converter + sane config file format
but yeh
 
Smarty.... ugh
 
6:31 PM
Nn
 
@DaveRandom the advantage of fpm compared to other SAPIs is that it's self contained... It's as easy as CLI to understand, in theory
 
@FlorianMargaine Conceptually yes
In practice... you clearly haven't read the source :-P
 
Morning room 11 people
 
Actually, a little bit :P
But I have an amazing ability... I can actually read ugly code
 
@LeviMorrison Yes please!
 
6:36 PM
@FlorianMargaine You can read minified code? Wow!
 
Did I say that? No. Can I? Well, yes.
...with the help of some tools :P
 
:P
That was one of the best new features in Firebug. Built-in de-minify
 
Chrome does that by default ;)
 
well, chrome dev tools has most (if not all) of firebug features...
 
6:40 PM
Although I am hating chrome more and more their latest feature where dom mutations are highlighted in the dev tools is pretty nice
 
@LeviMorrison are people actually using them? (PHP 4 constructors)
 
@BenjaminGruenbaum It's not common, no.
Code that has been migrated from PHP 4 to PHP 5 often still uses them, though.
 
Then assuming enough research has been put into verifying that - I don't see any point in keeping them - so removing them seems reasonable. In general removing things from PHP sounds like a good idea.
 
Not anymore. But it should be removed because it's potentially confusing
 
SO says rename them: stackoverflow.com/q/1883913/1348195 that's good.
 
6:44 PM
@Danack that was it! Thanks. Gonna fix php.net/manual/en/internals2.variables.tables.php example :)
... if I find out how
hm
 
I think you file a bug to fix docs
 
I have no idea how to work with docbook editor ._.
 
@FlorianMargaine It;s ok. Nobody does
:P
 
Well, I've created an RFC to remove PHP 4 constructors. Feedback on wording, examples, etc would be very appreciated!
13
 
@PeeHaa no, seriously...
I have no idea where to find the thing to edit...
 
6:47 PM
Good morning elevenarians.
 
morning
 
@FlorianMargaine It's either in SVN or the 'edit link on the page.
 
It's not in doc editor?
 
Also, godspeed.
 
6:52 PM
@LeviMorrison Consider adding more statistics, how many projects have primary constructors on GH with more than 3 stars and updated in the last year for example?
 
@BenjaminGruenbaum And how am I supposed to grep for that?
 
@ThW "fluentdom/fluentdom": "v4.1.1" seems to have been erased from existence..... :-P
 
@LeviMorrison well, you can write a script that takes the 10000 most popular PHP projects on GH, downloads them one by one, use a static analysis tool to detect PHP4 constructor syntax and report.
 
@LeviMorrison For the idea in general, +1 :)
 
You're a smart guy, you know the PHP engine very well, and I'm sure you're capable of scraping and downloading.
 
ThW
6:54 PM
@Danack it existed?
 
I coulda sworn using the old style constructors produced a deprecation notice under E_STRICT
 
@ThW Yes
I can upgrade to 4.1.3 I guess.....but deleting tags is not awesome...
 
ThW
I did a cleanup for composer support
that's why I am surprised
 
@LeviMorrison the proposal section could do with spelling out, in baby steps, exactly what the changes are going to be.
 
@salathe Isn't that what the implementation section is for?
 
6:59 PM
If you think it fits better there, sure.
 

« first day (1493 days earlier)      last day (3455 days later) »