Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJonathan Prada
7,039 PointsAn example of loose coupling vs tight coupling please?
What are some of the differences? i've done research on google but need a very simple example with some of the code that we've worked with here! any example appreciated :) thanks
1 Answer
Kenneth Love
Treehouse Guest TeacherSure, let me give it a shot. Won't be any code, though.
Django is a Python web framework that comes with auth built in, so you can create users, let them log in, etc. For years, Django's User
could only be the one that Django came with. Everything expected the class to live in a certain place and look a certain way. If you wanted some special new data stored about your user, you had to add a new class (since these classes tie into the database, they're called "models" and that's what I'm gonna use from here on) and then associate that model with your user model.
That's really tightly coupled. I can't, for instance, make a user that doesn't have a username, only an email address. Or change the rules for their passwords.
Eventually Django fixed this by loosening the coupling of the user model. It still includes the default one, but by changing a setting in your project you can say that some other model should be used for creating and validating users. The authentication system is no longer tightly coupled to the User
model.
Jonathan Prada
7,039 PointsJonathan Prada
7,039 PointsThank you Kenneth! this makes sense, I love Django. Need to get myself some of those laptop stickers.