• What are you working on? v7
    7,420 replies, posted
We can afford to be purely academical here, and the truth is, I can't think of a single situation where a singleton is good design...everyone's made good points, and once you're out in the real world you'll be judged by your choices, I'd just rather make an effort to teach good practices as much as possible (even if at times it seems obsessive) while we can. In closing, h2oooooo's implementation is very wrong®, I repectfully disagree with (but understand) adam's implementation, and i'd like yo have it recorded that I wrote this while doing a poop, and that my posterior is now a tad sore.
[QUOTE=StinkyJoe;34309080]We can afford to be purely academical here, and the truth is, I can't think of a single situation where a singleton is good design...everyone's made good points, and once you're out in the real world you'll be judged by your choices, I'd just rather make an effort to teach good practices as much as possible (even if at times it seems obsessive) while we can. In closing, h2oooooo's implementation is very wrong®, I repectfully disagree with (but understand) adam's implementation, and i'd like yo have it recorded that I wrote this while doing a poop, and that my posterior is now a tad sore.[/QUOTE] Next thread's tagline is going to be "StinkyJoe posts from the loo"
[QUOTE=StinkyJoe;34309080]I'd just rather make an effort to teach good practices as much as possible (even if at times it seems obsessive) [/quote] Good practices. Using PHP. wut? We all need to make sacrifices somewhere :D [quote] I repectfully disagree with (but understand) adam's implementation, and i'd like yo have it recorded that I wrote this while doing a poop, and that my posterior is now a tad sore.[/QUOTE] What's wrong with mine? And if you had a site with 80 different classes, not all of which are used simultaneously...that'd be awful, but half of which needed database interaction, how would you pass the database connection to every single one? (RUN RUN-ON SENTENCE RUN) I've been working on my PHP framework for 5 years. And I've done hundreds of tests and built 150+ commercial websites with it. I just recently abandoned PHP entirely in favor of Python, but I feel like I've made very informed decisions in the creation of my PHP framework.
I've been working on revising my sub-navigation menus. Opinions? [img]http://katanaproject.com/screens/2.png[/img]
[QUOTE=adamjon858;34309352]Good practices. Using PHP. wut? [/QUOTE] Well, that's part of the problem with PHP in general. [QUOTE=adamjon858;34309352] I've been working on my PHP framework for 5 years. And I've done hundreds of tests and built 150+ commercial websites with it. I just recently abandoned PHP entirely in favor of Python, but I feel like I've made very informed decisions in the creation of my PHP framework.[/QUOTE] I have no doubts about the palpable qualities of your framework, but I've seen snippets you posted here (please do correct me if I'm mistaken), and it was usually quite far from what I'd call ideal or well designed - no doubt functional, and you may say that at the end of the day it's the base line final product that matters most (and I'll be hard pressed to disagree), but like I said, here we can afford to judge from our golden (or in my case, porcelain) thrones, far from the development trenches. To answer your question: [QUOTE=adamjon858;34309352]And if you had a site with 80 different classes, not all of which are used simultaneously...that'd be awful, but half of which needed database interaction, how would you pass the database connection to every single one?[/QUOTE] I'd start by asking why in the hell 40 of your (hypothetical) classes need access to a database connection? Separation of concerns dictates that I wouldn't have more than one instance per connection managing the database interfacing, and turning that into usable data structures - which would in turn only be passed along where needed. Don't design super methods, delegate tasks and only provide the minimum access/data/components required to perform those tasks. Did I ever mention I love discussing this sort of shit? (I hope I don't come off as bashing you or your framework, adam, these discussions can quickly delve into ridiculous levels of pedanticness).
[QUOTE=StinkyJoe;34309080]We can afford to be purely academical here, and the truth is, I can't think of a single situation where a singleton is good design[/QUOTE] Literally any design where you need a single instance of something, which entails an initialization process, for any given lifetime? Adam's example is a perfect one. Singletons are more important outside of web development where systems are [i]required[/i] by design to have a single instance of something which requires initialization. Web developers have what, databases? Even that, if you want to be messy doesn't [i]require[/i] one-time instantiation. Developers working on desktop applications have to deal with rendering states, hardware interaction, low-level networking, low-level filesystem management, and the list goes on for where singletons are needed. In web development, such patterns aren't as common or necessary but rather are more of a functionality convenience and plain good practice. [editline]20th January 2012[/editline] You guys are complaining about issues which are largely relevant in performance situations, not necessity ones.
[QUOTE=amcfaggot;34310477]Literally any design where you need a single instance of something, which entails an initialization process, for any given lifetime? Adam's example is a perfect one. Singletons are more important outside of web development where systems are [i]required[/i] by design to have a single instance of something which requires initialization. Web developers have what, databases? Even that, if you want to be messy doesn't [i]require[/i] one-time instantiation. Developers working on desktop applications have to deal with rendering states, hardware interaction, low-level networking, low-level filesystem management, and the list goes on for where singletons are needed. In web development, such patterns aren't as common or necessary but rather are more of a functionality convenience and plain good practice. [editline]20th January 2012[/editline] You guys are complaining about issues which are largely relevant in performance situations, not necessity ones.[/QUOTE] Nobody's complaining, we're having an interesting discussion, sheesh! Let me start by pointing out that "using an instance of x" does not equal a singleton. This is a singleton(ish) (php-pseudo-code): [php] class Foo __construct() if( static::$instance ) throw Exception "cannot instantiate" static getInstance() if( !static::$instance ) static::$instance = new __CLASS__ return static::$instance [/php] This is not: [php] class Application start() $this->http = new Http; $app = new Application $app->http->end(200) [/php] There's hardly a good reason to hold global state in an object-oriented application - maybe there's some reasons, but I've yet to come across a valid use for it. Swifturb made a good point about how the life-cycle of a PHP script reduces the concerns of global state, but it's still bad practice (golden throne, etc).
It seems to me more like you're referring to a single instance of something as being a single object and not a singleton, which is in part what a singleton is, a sole instance.
[QUOTE=StinkyJoe;34310432]Well, that's part of the problem with PHP in general. I have no doubts about the palpable qualities of your framework, but I've seen snippets you posted here (please do correct me if I'm mistaken), and it was usually quite far from what I'd call ideal or well designed - no doubt functional, and you may say that at the end of the day it's the base line final product that matters most (and I'll be hard pressed to disagree), but like I said, here we can afford to judge from our golden (or in my case, porcelain) thrones, far from the development trenches. To answer your question: I'd start by asking why in the hell 40 of your (hypothetical) classes need access to a database connection? Separation of concerns dictates that I wouldn't have more than one instance per connection managing the database interfacing, and turning that into usable data structures - which would in turn only be passed along where needed. Don't design super methods, delegate tasks and only provide the minimum access/data/components required to perform those tasks. Did I ever mention I love discussing this sort of shit? (I hope I don't come off as bashing you or your framework, adam, these discussions can quickly delve into ridiculous levels of pedanticness).[/QUOTE] Imagine a site that has classes spread across various things, Boards, Profile, Login, Purchases, Ranking, etc. It's easily done like that in a regular large site developement. Creating a new class every time would be absoloutly ridiculous, both in a logical and in a performance sense.
[QUOTE=andersonmat;34310228]I've been working on revising my sub-navigation menus. Opinions? [img]http://katanaproject.com/screens/2.png[/img][/QUOTE] That's lovely, but if I were you I'd change a few things (take this as an entirely personal opinion): [img]http://gabrielecirulli.com/p/20120120-204459.png[/img][img]http://gabrielecirulli.com/p/20120120-204510.png[/img] The text-shadow and bright color look a little out of place here. Instead, I'd tone down the color (just a slight bit) and set the font-weight to bold on all buttons and badges. Also, if on the [B]unread[/B] badge you've used a gradient, I'd suggest you don't: it makes it look like a button when in fact it isn't. It might also become even more badge-like if you removed the darker 1px border and placed it alongside the title of the message instead of having it on the right side. [img]http://gabrielecirulli.com/p/20120120-204644.png[/img] These buttons look incredibly nice but at the same time they look as if they're depressed (not psychologically :v:). Try to push the box-shadow a downwards bit and either have them like that or add another white box-shadow on top to show an highlight as if light was coming from the top. Also, the logo should play an important part in such a design: [img]http://gabrielecirulli.com/p/20120120-205025.png[/img] right now it looks a little small. I'd suggest that you use the nice amount of space you have on that bar and try to make the logo a little bigger and maybe use a bold font to give it more importance.
[QUOTE=h2ooooooo;34310658]Imagine a site that has classes spread across various things, Boards, Profile, Login, Purchases, Ranking, etc. It's easily done like that in a regular large site developement. Creating a new class every time would be absoloutly ridiculous, both in a logical and in a performance sense.[/QUOTE] [QUOTE=amcfaggot;34310657]It seems to me more like you're referring to a single instance of something as being a single object and not a singleton, which is in part what a singleton is, a sole instance.[/QUOTE] No, that's not a singleton, and you don't create a new class every time you need to access the database - your application controller has a database connection (an instance, or an instance of a controller that knows how to use the connection instance), and it keeps it for itself, without introducing global state - theoretically speaking you should be able to instantiate an infinite amount of application controller instances without side effects (besides maybe your server catching fire), that's my whole point. I know about large site development, every day I work on various different applications, most with at least a couple hundred components.
A singleton is a sole instance. Singleton as in [i]single[/i]ton. You're arguing more about whether or not I'm using new once and retrieving the same memory over and over from a method vs if I'm using a single object defined outside of the class definition itself more than the actual usage of a singleton. [editline]20th January 2012[/editline] That is to say you're talking more about the concept of something along the likes of an initialization on demand holder. [editline]20th January 2012[/editline] In fact, all of your examples of singletons are lazy initializations.
[QUOTE=amcfaggot;34310815]A singleton is a sole instance. Singleton as in [i]single[/i]ton. You're arguing more about whether or not I'm using new once and retrieving the same memory over and over from a method vs if I'm using a single object defined outside of the class definition itself more than the actual usage of a singleton.[/QUOTE] I'm arguing about the difference between using a singleton (which introduces global state and constraints) and instantiating a class within a component and sharing it downstream (which is the right thing to do). Here's an example: you have an application, it needs a database connection, you think to yourself "Great! Time to apply those great concepts I learned from PHPMaster.com! I'll use a singleton - single means it's cheaper and will make my PHP fast!" [I]- - two hours of singleton-related development later --[/I] "Great! Now I have my own ConnectionClass, and I can use its static ::getInstance() method to have access to its methods without creating a new instance every time! Uhmm, my application would really benefit from this new component, ComponentX! Let's see the requirements...right, it needs to connect to a another database...oh crap, my ConnectionClass nonsense is useless now, since I can't get a new connection instance for another database link :( " :( To pre-emptively answer questions: Q. But duh, it's not like I'll EVER need more than a single database connection in my application! A. Great! It's still poor design, but whatever works for you! Q. But duh! I can just have ConnectionClass2, which extends from ConnectionClass but holds a link to database 2 A. Ouch Q. But duh! StinkyJoe, why are you being so pedantic about this? A. Golden throne, good practices, do as I say not as I do, yadda yadda yadda.
If you're abstracting your database connections in a way that only allows a single database connection perhaps you should rethink why you need to use a singleton and ask yourself if you've written a proper singleton in the first place.
[QUOTE=amcfaggot;34310992]If you're abstracting your database connections in a way that only allows a single database connection perhaps you should rethink why you need to use a singleton and ask yourself if you've written a proper singleton in the first place.[/QUOTE] If you have a database connection class that does not map directly to a single lower-level connection, I don't think you really understand object-orientation at all, and question what the hell is the class's purpose after all. [editline]20th January 2012[/editline] Maybe if you have a DatabaseConnectionAggregator class or something, but even I think that's fucked up.
That's about as valid as saying if you have a filesystem class which doesn't map directly to a single file that the class doesn't have a legitimate purpose.
[QUOTE=StinkyJoe;34311049]If you have a database connection class that does not map directly to a single lower-level connection, I don't think you really understand object-orientation at all, and question what the hell is the class's purpose after all.[/QUOTE] can you write more words because this is a strange thing to say
[QUOTE=amcfaggot;34311150]That's about as valid as saying if you have a filesystem class which doesn't map directly to a single file that the class doesn't have a legitimate purpose.[/QUOTE] No...that's like saying if you have a File class instance that maps to ALL files in the system you need to learn that you don't use OO constructs to emulate namespacing, or like saying if you have a FileSystem class that you can only use once for a single file per execution, you need to learn what object-orientation means. [editline]20th January 2012[/editline] [QUOTE=Catdaemon;34311217]can you write more words because this is a strange thing to say[/QUOTE] Can I just paste straight from lipsum.net or...? Seriously now, read what I just said above, it should clear it up.
I think we're blurring the line of overly-pedantic discussion. We all raised valid points. Let's agree to disagree.
[QUOTE=TerabyteS_;34310692]That's lovely, but if I were you I'd change a few things (take this as an entirely personal opinion): [img]http://gabrielecirulli.com/p/20120120-204459.png[/img][img]http://gabrielecirulli.com/p/20120120-204510.png[/img] The text-shadow and bright color look a little out of place here. Instead, I'd tone down the color (just a slight bit) and set the font-weight to bold on all buttons and badges. Also, if on the [B]unread[/B] badge you've used a gradient, I'd suggest you don't: it makes it look like a button when in fact it isn't. It might also become even more badge-like if you removed the darker 1px border and placed it alongside the title of the message instead of having it on the right side. [/QUOTE] Thanks, I'll take a look later and tone down the intensity of the colour and look into making it fit in more appropriately. As for the notification bubble for unread messages, I agree, it definitely looks like a button and I should make it "flat". [QUOTE=TerabyteS_;34310692] [img]http://gabrielecirulli.com/p/20120120-204644.png[/img] These buttons look incredibly nice but at the same time they look as if they're depressed (not psychologically :v:). Try to push the box-shadow a downwards bit and either have them like that or add another white box-shadow on top to show an highlight as if light was coming from the top. [/QUOTE] Definitely agree! It'd be a good :active or :hover state, but not how they are currently. I'll remove the inset gradient and see where that puts me. [QUOTE=TerabyteS_;34310692] Also, the logo should play an important part in such a design: [img]http://gabrielecirulli.com/p/20120120-205025.png[/img] right now it looks a little small. I'd suggest that you use the nice amount of space you have on that bar and try to make the logo a little bigger and maybe use a bold font to give it more importance.[/QUOTE] Roger that. I also have a real logo in the works that'll get put up there. I appreciate the feedback! :)
[QUOTE=amcfaggot;34311283]I think we're blurring the line of overly-pedantic discussion. We all raised valid points. Let's agree to disagree.[/QUOTE] Shall we...kiss on it?
that stuff isn't suppose to leave that chat
[QUOTE=amcfaggot;34311973]that stuff isn't suppose to leave that chat[/QUOTE] Hey what are you doing come back inside we're not done yet.
Spent most of today installing and configuring opencart. Damn its some good software. [url]http://www.gametechdeals.co.uk[/url]
I love that part on your site where [editline]21st January 2012[/editline] Feel free to use my NivoSlider, it supports webkit arrow keys! [url]https://raw.github.com/Jaybuz/Nivo-Slider/master/jquery.nivo.slider.pack.js[/url]
What does opencart actually do? I've always wondered wether it's just a thing that links up to paypal, or something that creates a skeleton of a shop and you have to fill the blanks?
[QUOTE=Rhymenoceros;34320797]What does opencart actually do? I've always wondered wether it's just a thing that links up to paypal, or something that creates a skeleton of a shop and you have to fill the blanks?[/QUOTE] Its more or less an entire package of the stuff you'll need to set up a webstore, the fact its open source means that theres hundreds of mod and addons too, its really nice.
[img]http://gabrielecirulli.com/p/20120121-181038.png[/img] A logo for my dad.
[QUOTE=TerabyteS_;34325037][img]http://gabrielecirulli.com/p/20120121-181038.png[/img] A logo for my dad.[/QUOTE] Nice and clean - the colours on the shutter really adds something to the logo. Good job! :)
[QUOTE=h2ooooooo;34326080]Nice and clean - the colours on the shutter really adds something to the logo. Good job! :)[/QUOTE] Thank you! Also, first experience with InDesign and already lovin' it: [quote][t]http://www.gabrielecirulli.com/p/20120121-194327.png[/t][/quote]
Sorry, you need to Log In to post a reply to this thread.