No. I know Christmas is around the corner but I'm not talking about gift wrapping.
Any programming language you work on, will have great built in classes for your common tasks. e.g. Database access, File System, web services...etc.
You can use these directly in your other classes perfectly fine and safely. I personally Wrap these up in my own class with it's own properties and Methods...
As I highlighted recently, I've just started using Xojo for work. On my first project I happily wrapped up my
PostgreSQLDatabase calls into my own class called
DBConnection as I learned how to use them. I exported this class so I could re-use it. My class saved the
PostgreSQLDatabase object to it's own private variable and called methods from there.
I made a wrapper method in this, called
SelectData which mapped directly to Xojo's
SQLSelect, which returns a
public Function SelectData(Sql As String) As RecordSet Return Self.CurrentConnection.SQLSelect(Sql) End Function
It's that simple!! So I hear ya...
Why Is that Useful??
Can't you just call that directly in your code??
How many coffee breaks did you take whilst writing that??
Well I'll answer them now!
In the update there was a new Data Type called
RowSet and with it a slightly renamed method for selecting data from a database.
The advantage in this new data type is with error catching. The
Recordset had "Silent Errors" where the software you are building would just carry on as if the select data had produced no data.
public Function SelectData(Sql As String) As RecordSet Return Self.CurrentConnection.SelectSQL(Sql) End Function
We've basically gone from..
so to answer the question, Why is that useful?
If everywhere in my code, I had called
SQLSelect(Sql), to get data from my database, I would've had to have found them all to change it.
In my case the only change I made was the one you've just seen.
Wrapping up the code meant I could make that change in function name in one spot rather than various spots throughout my program.