last day (26 days later) » 

12:20 PM
:P
 
@throck95 points 1 and 2 are "where are your custom exception classes, because without them I don't understand why you're doing that which you are doing"
@syb0rg at throck's question, maybe? Have a read first, though
 
@Pimgd I understand that part, they do almost nothing different than PDO it was just creating an extension of PDOException for the naming scheme
at this point not worth adding them in for possible answer invalidation
 
which point do you not get?
3a - not failing properly...
3b - violation of srp
3c - wrong logging system
3d - yay, you didn't post your credentials all over the internet!
 
I guess I just wasn't looking at it the right way
 
... did the confusion go away or did you stop caring about it?
 
12:24 PM
I think 2 comes off weird bc the whole goal here was to extrapolate the DB out of the controller
That being said, I do understand his point of multiple instantiatioins
 
@throck95 2a is about wrong level of abstraction
the database wrapper has business logic inside of it (select queries with empty resultsets are an error)
 
I could probably move it to a global variable in the controller and then add in a factory structure to only instantiate if its null
 
@throck95 why would you want a global variable
 
i wouldn't, which is why i originally didnt
 
2b is about that if you were to build a true abstraction layer, then you are a database
 
12:26 PM
but for this instance, I could see the logic behind having one
 
throwing database or queryexceptions
and there basically shouldn't be a single mention of "PDO"
because otherwise, you have a leaky abstraction
In software development, a leaky abstraction is an abstraction that exposes to its users details and limitations of its underlying implementation that should ideally be hidden away. Leaky abstractions are considered problematic, since the purpose of abstractions is to manage complexity by concealing unnecessary details from the user. == History == The term "leaky abstraction" was popularized in 2002 by Joel Spolsky. An earlier paper by Kiczales describes some of the issues with imperfect abstractions and presents a potential solution to the problem by allowing for the customization of the...
 
Yea I understand that, which is why everything is private except for a few methods
only public methods are __construct, query, and couple of getters for methods on the private PDO object
 
lemme know if there's a specific part you don't understand
 
@Pimgd how do I link pieces of it like you did in this post
 
@throck95 "link pieces"?
ah try > content
> content
 
12:31 PM
> PDO provider class and let your calling code just interact with the PDO object itself
what use would that have over what I'm already doing if my largest goal is to limit what the user has access to
 
> I honestly think you would be better just having a simple PDO provider class and let your calling code just interact with the PDO object itself (PDO is an abstraction after all).
@throck95 if you aren't properly abstracting the PDO layer away AND just restricting functionality
then maybe you're better off NOT using a wrapper
@throck95 and "limit the user" != "limit the programmer"
 
@Pimgd in this specific situation I have direct access into the database itself, personally I'm under the belief of why put the work into creating something if it's already available and accessible
@Pimgd so what do I need to do to "properly abstract the PDO layer", ideally that is
 
@throck95 don't extend PDOexception
don't throw errors for empty result sets on select
... this might be easiest to do if you looked at another database
and considered what you would have to do to write 1 interface that can be used by both implementations
raw mysql is not gonna throw PDOException
 
No it won't but I am trying to catch when the PDO Prepared Statement failed to create or execute
for that instance, I'd honestly rather throw an exception than return a bool
 
@throck95 that's perfectly fine. But in that case, the exception is not a PDOException
maybe it wraps a pdoexception
map it to meaningful types
 
12:40 PM
Mind if I move this to the nth?
 
I don't know enough about PDO,
but "DatabaseUnavailableException" or "InvalidArgumentsForPreparedStatementException"
(too wordy, but something your application can use)
 
here I'll update the question to include PDOQueryException which is the custom exception i made. I don't think that would invalidate his answer as he asked to see it
 
I mean... it's squarely on topic in here, but getting a little long and it's basically just you two discussing...
56 messages moved from The 2nd Monitor
 
Words!
 
appear!
 
12:45 PM
on the screen...
 
Anyway the thing is that if you write a database wrapper it should hide implementation details
right now you're leaking implementation details via the exceptions
3
Q: Phishing Project Error Logging

throck95Moving on to the next steps! Previous review was here. The idea here was to implement suggestions made by @hd/@Pimgd and then implement an effective way of tracking and logging results when an exception is thrown. With that said, my focus is still on security of my application, but now I also rea...

question link because it's not in this chatroom
 
there I added in the PDOQueryException
 
3 2 1 possible answer invalidation...
 
yea that's why I didn't originally, but he did ask for it in the answer so
 
12:50 PM
you really ought to have this discussion with them
but his core point seems to be that there's no added value from the wrapper
 
so is there any real use that comes from just separating the code?
 
If you move to another database
 
that was the biggest goal there, was to get rid of redundancy and extrapolate the code
 
it got rolled back
 
i saw
thanks tho, I'll start by using what I do agree with and understand then come back to what needs work
@Pimgd from what you briefly saw with the exception tho, do you think that it causes leaks? or would that be better to cover leaky abstraction in the follow up once ive addressed the other aspects
 
1:57 PM
@MikeBrant hey
 
2:08 PM
Will add my thoughts around just directly using PDO and dumping this DBManager class. In most cases, executing a query using PDO takes 3-4 lines of code. I question the value of getting that down to 1-2 lines vs. the cost of maintaining a class such as this, which in essence proxies requests into PDO anyway. To get this class as fully-featured and thoroughly tested as PDO is going to take a lot of effort.
 
I assume you read up above, but the largest component here was really to extrapolate out material as my controller was getting messy. I figured creating a centralized management of the database was smart and usually is. That being said, I probably just haven't implemented it correctly.
 
Think about perhaps focusing on providing a class that can provide the valid PDO object in a good state (and perhaps utilizing a single shared connection) to whatever caller needs it. I would also think about having the PDO object passed to consuming classes via constructor or public method (I generally prefer constructor for most cases) such that you validate the object being passed as PDO object by enforcing this on the parameter. This would be a dependency injection approach.
 
I understand the concept, but preferably I want to try to limit dependency as this class will only be used by users. I ideally want it to be limited and controlled to only what is necessary to accomplish the job that needs done. Can this still be done that way or is what I'm doing moving in the right direction?
 
"I ideally want it to be limited and controlled to only what is necessary to accomplish the job that needs done." Your classes where your business logic is implemented should determine what the allowable access patterns are against the database, not the database access object itself.
 
Is that not what the idea of composition is though? Or is composition the completely wrong way to be going here?
 
2:18 PM
I don't see where inheritance is applied in this example.
 
wrong term, edited
 
ah
Yes it definitely is the idea of composition - to drive towards the model of classes/patterns that work together via composition.
So if you were going to frame your DBManager class as a "model" vs. a DB Management class. This might be more along the lines of what you seek to implement.
 
I think that was my idea, PDO was really going to be the management. I was just trying to create a wrapper/interface/model/etc that facilitated and only revealed what is needed
if you haven't noticed, naming is a struggle of mine
 
By model I mean a class (oftentimes abstract and intended to be extended with concrete implementation) with which to set the allowable patterns for interacting with the database to do things such as CRUD operations.
In this pattern, business objects - users, products, etc. - would oftentimes by the concrete implementations of the abstract model class.
 
so if I didn't implement business object classes for my database (only have User), is this even viable?
The biggest thing is I want everything separate out of the controller. The controller should only be logic and calling separate classes and methods to do what needs done
 
2:26 PM
If it is a simple application, I would tend to minimize the "moving parts" and would probably just build a user class that takes a PDO object as dependency and have that class implement appropriate DB access patterns.
 
senior thesis - probably not that simple :P
The only thing I have a User Object for is tracking authentication to the GUI
 
Ah I see... If for school, I would then highly think about dependency injection, this is probably the most widely used approach in industry for new applications.
Have to run... hope to have helped.
 
thx
this room will likely stick to this for a while - big big big project
not rubberduck but i'm creating a large chain of posts
 

  last day (26 days later) »