Jump to content

RuleBritannia

Members
  • Posts

    92
  • Joined

  • Last visited

Everything posted by RuleBritannia

  1. So using the factory pattern, does this allow resource sharing? As for autoloading and including I should not of mixed them throughout this thread, but what I was trying to say is if I had a file with the following code db.php $db = new PDO('... If I include this everywhere a db instance is needed, how is this different to calling a factory pattern class(Which creates or reuses a instance)? Arnt either of these methods using a new created instance at the begining and resuing a instance if called anytime after?
  2. I should of been more specific, If I instantiate a class(lets say connection) and store it in a variable, then include this everywhere needed and pass around in constructors, why would I need a factory? As for the term reuse meaning in a code reuse context, I dont believe that is how it was meant, I am sure I have seen on many occasions people saying "you dont want to be creating a new connection, you reuse a database connection already opened." The problem I have here is understanding how if we use factory or autoload, each one instansiate's lets say a connection(with new), how is this reusing a connection?
  3. Hello I hear alot of talk about reusing a database connection and attempts to solve this. I came across this post on stackoverflow but am having difficulty understanding as to how this is any different than just creating a instance in a single file and including it via include, require or autoload wherever a db instance is needed. The pattern talked about in the post is the factory pattern, it seems that the factory is responsible for creating the instance, something which I thought autoloading did without this additional code? Another thing I am still confused by with all the reuse talk - If 2 seperate users request 2 different pages on our server(2nd user 0.1 second behind the other user) which both refer back to the same db file/factory, are 2 instances created? or is the previuos users instance somehow used aslong as there request has not finished? I thought that the server would make new fresh requests/variables/instantiation etc all over again for every user, perhaps I am wrong. Thanks in advance.
  4. I assumed something like this, Thanks for your input guys, I will give it a shot either way and post back my results.
  5. I voted notepad++, Although I should really be moving onto some type of IDE I believe, Or so im told.
  6. Hello I wondered if anybody here had any hands on experience with removing some components from there laptops? One componenet im specifically interested in is the mic. With this being said, Im also aware of removing the drivers and so on to render the componenet "unavailable", but this is not my concern. I also mentioned laptops as the circuitry could be different to a desktop, Due to the size constraints I am wondering whether alot of the components are wired in a way that removing one can cause big problems elsewhere. Thanks for any insight/help in advance.
  7. When you want to share your method of how you obtain spontaneous unlimited computational power please PM ME @kicken I think your idea is suffiicient,.
  8. They most likley will not have thousands of errors, But its not impossible. @that you don't want these things to be processed, but rather rejected at input. They will not be rejected at input, Once they error, they will be moved to another table so they dont clutter the Image table whilst they are not possible to be processed. The project is also only for me. @help validate the input while the user is in the act of doing it so as to prevent as many 'rejections' as possible. This is not possible, That would mean processing thousands of rows at once. The current method is rows get put in the Image table, processed at a reasonable rate within a parallel limit, If there is some file meta/file corrupt/file type/libary error etc, This will never fix itself by just reattempting to process it, The only way of fixing this is manually checking/deleting/updating/etc the file or libary which processes it. @Do you really want to be reviewing dozens(?) of errors every day? This is irrelevant to wherever/however they are handled/placed. Also its worth mentioning as I said before, I cannot foresee every possible "error", the plan is to reduce as many as possible, And each time a error does surface, I examine it and update the script to rule it out if possible before processing, But sometimes this is not possible without processing.
  9. hmm, But we can be inserting thousands of rows here daily, Not sure if its a good idea to clutter it with potentially thousands of rows which at that current time cannot be processed. Im still thinking of the best option for this, Thanks for your input.
  10. When i say errors its not the best word, I mean it in a scenario that if we use for example a libary to process some data, if that libary does not have the capabilities for the image file type, we will move it to error/concern table, so we can deal with it later, rather that leaving it in the que, to be included again a the next loop iteration, or marking it as "problem" and cluttering the table, it seems best moved to error/concern table, as it is not possible to solve this with our current libaries.
  11. Processing error just within the script logic, eg image type not reconised, with regards to solving the problems, some problems I cannot foresee so it may not be possible to solve them, ontop of this the server must use its resources elsewhere, so we move the row to errors, and move on. I thought to have this column as a place I can consolidate all errors to, and check here every now and then to see any problems.
  12. There is a function in php called http://uk1.php.net/round round(9.5, 0, PHP_ROUND_HALF_DOWN); returns 9
  13. Hello If we had multiple tables which hold data to be processed IMAGE +----+-----------+ | id | image | +----+-----------+ | 4 | test.png | | 5 | bird.png | +----+-----------+ ORDER +----+-----------+ | id | order | +----+-----------+ | 4 | 100000045 | | 5 | 100000046 | +----+-----------+ When a processing error occurs, I thought to move the row to a table called error/attention/concern etc, To keep the table clean. Which would look something like this. ERROR +----+-----------+----------+-----------+ | id | table_id | image | order | +----+-----------+----------+-----------+ | 1 | 4 | test.png | EMPTY | | 2 | 5 | EMPTY | 100000046 | +----+-----------+----------+-----------+ However, This table will have to have corresponding columns for IMAGE and ORDER, But then we have a problem of storing empty/null values for the columns which are not needed on insertion here, This does not seem right. Has anybody had a similar issue before like this? Im sure there maybe a more definitive way of doing this. I also thought possibly just have 2 rows here, and enter a serialized array of data, but that seems even worse than this. Or finally I could possibly make 2 more tables, IMAGE_ERROR, ORDER_ERROR. But upon adding new processing technologies, I would need to add 2 new tables each time. Thanks in advance for any help/advice/answers.
  14. Lets say you had a function which checks to see if all values in array 1 are less than all values in array 2 You may need this functionality in many different things. Will read this now, Thanks
  15. Hello question is aimed @ experienced OOP'ers I just wondered how you handle a function which you use in multiple classes. You could write it fresh everytime in each class, Or make a standalone function in a php file and include it, But Im sure there is some better ways of doing this? So far with research it seems some people are making static "utility" classes, which they can call without initializing. Regards
  16. If we have a class which loads a row from the database and can update it etc, +-------------------------------+ | id car colour price fuel | +-------------------------------+ | 2 bmw blue 22000 petrol | +-------------------------------+ If within this class, We run a update to change colour from blue to green, We can maintain this green setting without needing to requery the database, as we can change our internal value of $colour within our class to reflect the change. However, lets say another php script simultaneously does some work on this table, and it changes price from 22000, to 20000 In our other object, we think we have up to date variables, But unknowingly to us we do not. We can requery the table with ID each time to change all internal variables, But this isnt efficient. Is it possible to link all changes to a central object, and if another script access or updates etc, they do it within this object, that way the change will be reconised anywhere. Thanks in advance.
  17. I think I have found some principles to abide by to reach a ultimate solution. data mappers or active record, But I think data mappers are best in my case as I want to stay within SRP. I am trying to store a row from a table, So I can return values when needed, whilst also updating these field(s) when needed, However a new problem occured, Which is when I perform a update and change a value, the row stored in the object will now not reflect the updated field in the database, so a requery would be needed, But I believe active record and data mappers cover this.
  18. What would you say is best practice? Thanks in advance for any answers/advice.
  19. Yes I do have a class specifically for fetching the data from the imagehost, But according to SOLID principles, I should be making a second class for database actions, But within the code this seems illogical when it could be handled within 1 class.
  20. Wondering if this approach is considered good. -> If I was to write a db wrapper, along with a fetch wrapper, And query it like, $objdb->objfetch->imagecount();, Im guessing this would work, Also seperating db actions from string actions etc.
  21. The images are not on my server, Lets say for exmaple imageshack.us, I login, check total images, logout.
  22. Hello So I must return a value from somewhere, lets say image total uploaded count from a user account check. The value is returned, used within a loop etc. I also want to update my database with that figure, and a timestamp when it was checked. I know I can put this inside one function, so that after the value check, I can update a table and so on, But this breaks the single responsibility principle, as my function will be doing multiple things. Im curios how you would do this sticking to SOLID principles whilst not making a complete mockery at the same time. Thanks in advance.
  23. I meant the term gateway just as a abbreviation, I should have said wrapper. In regards to passing the DB to trips, Does this not break the single responsibility principle? Trying to abide by all these principles isnt easy.(for me anyway). Edit : Nvm, Im just going to get it done, Cannot learn and apply every OOP principle in this space of time, My work is getting nowhere because of this. Thanks for all the help"
  24. Hello I believe I have already done this, But my main question is where does db interaction sit within this? I could put the database handling inside the classes which inheirt the template and decide which methods to use. Or I build a gateway and parse all the small classes through this gateway before other stuff? Here is a good comparable example. Do I handle my database interaction within PackageA and PackageB? Or do I build a separate class, Which I parse the output from PackageA,PackageB and so on? This way would abide by the DRY principles, But that still doesn't mean its right. Thanks in advance.
  25. Yes that would work, with the setter of that object not being in a __construct. With regards to this overall question, What about many properties that have been set later during the objects use? example var $date var $time Im guessing we should set all properties to null when we assign a new value to the "main" property? otherwise, we will be using older set values of properties set from a previous "main" value, (within the same new instance however) However if we just destroyed the object and started new, all of this would be done automatically, But I am wondering which is the professional way?? kill object, rebuild new or build once, reset all with new use(via method to set all var inside to null) Thanks in advance.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.