Our rules have been updated and given their own forum. Go and look at them! They are nice, and there may be new ones that you didn't know about! Hooray for rules! Hooray for The System! Hooray for Conforming!
Our new Indie Games subforum is now open for business in G&T. Go and check it out, you might land a code for a free game. If you're developing an indie game and want to post about it, follow these directions. If you don't, he'll break your legs! Hahaha! Seriously though.

[Programming] Thread: Restricting masking of red pandas since 2013.

17891012

Posts

  • gavindelgavindel Registered User regular
    Speaking of Java hate, I have to learn Java for my internship. I "learned" it once, in the sense that I could make tiny 50 line programs that occasionally worked, but that probably won't cut it. Anyone have a favorite online Java learning repository?

    If they ask me to do OOP, I'm gonna hang myself. I wouldn't have gone back to school if I already knew all that stuff.
    Aether drive online. Blogs, rants, gaming nerdity. http://www.aetherdrive.com
  • InfidelInfidel It's not Infidel, it's INNNNNFIDELRegistered User regular
    gjaustin wrote: »
    Infidel wrote: »
    gjaustin wrote: »
    Infidel wrote: »
    Wait, how the hell do you associate vim with Java?

    It's not a direct association, but rather a chain of logic.

    People who program in Java are more likely to love them some Unix.
    People who love them some Unix are more likely to be insane.
    Insane people are more like to use vi.

    Yeah, I am gonna guess that some people have skewed experiences with "Java developers" but the majority are actually the opposite and bloated IDE dependent, doing stuff like Eclipse in Windows. :)

    I guess I should have clarified better that I'm talking more about the people who write the tools.

    You know, the people who didn't bother to develop a GUI to go with Maven.

    Okay now you make perfect sense! :)

    Yeah, when I think "Java" in general I'm gonna think of Java developers. Poor sods.
    Play D&D 4e? :: Check out Orokos and upload your Character Builder sheet! :: Orokos Dice Roller
    The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
    Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
  • InfidelInfidel It's not Infidel, it's INNNNNFIDELRegistered User regular
    gavindel wrote: »
    Speaking of Java hate, I have to learn Java for my internship. I "learned" it once, in the sense that I could make tiny 50 line programs that occasionally worked, but that probably won't cut it. Anyone have a favorite online Java learning repository?

    If they ask me to do OOP, I'm gonna hang myself. I wouldn't have gone back to school if I already knew all that stuff.

    Prepare for OOP!
    Play D&D 4e? :: Check out Orokos and upload your Character Builder sheet! :: Orokos Dice Roller
    The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
    Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
  • bowenbowen Registered User regular
    OOP is a concept, you should know how to use it language agnostically, knowing the implementation in each daughter language is just a matter of practice.

    Learn ye some OOP.
  • gavindelgavindel Registered User regular
    Maybe its just too simple, and that's why I feel baffled by it?

    "Package the data into bundles, work with bundles using outside calls depending on what you need."
    Aether drive online. Blogs, rants, gaming nerdity. http://www.aetherdrive.com
  • gjaustingjaustin Registered User regular
    edited May 2013
    gavindel wrote: »
    Speaking of Java hate, I have to learn Java for my internship. I "learned" it once, in the sense that I could make tiny 50 line programs that occasionally worked, but that probably won't cut it. Anyone have a favorite online Java learning repository?

    If they ask me to do OOP, I'm gonna hang myself. I wouldn't have gone back to school if I already knew all that stuff.

    Don't worry. OOP is easy. I mean, really, really easy. I used to explain it to sales people all the time, so I have no doubt you can manage it.

    Objects are responsible for data and actions. So a Circle class has a radius variable and an area method.

    Objects are also responsible for protecting their data from misuse, by making it either public, private, or protected.

    Inheritance is where you have a class that's a more specific "kind" than another class. So Square inherits from Rectangle inherits from Shape. (Circle also inherits from shape).
    class Rectangle
    {
         private int width;
         private int height;
    
         public void setWidth(int w) { width = w; }
         public void setHeight(int h) { height = h;}
         public int getArea() { return width  * height; }
    }
    
    clase Square extends Rectangle
    {
         public void setWidth(int w) {
             base.setWidth(w);
             base.setHeight(h);
         }
    
         public void setHeight(int h) {
             this.setWidth(h);
         }
    }
    
    //And you get Square.getArea() for free
    
    

    Interfaces are when something isn't of a specific "kind", but you still access it in the same way
    public interface RegularPolygon {
         int getNumberOfSides();
    }
    
    public class Square implements RegularPolygon {
        public int getNumberOfSides() { return 4; }
    }
    

    Now my favorite example, vehicles!
    public abstract class Vehicle {
        protected int velocity;
        protected int position;
    
        public abstract void makeUsGo(); // wheeeeeee
        public void tick(int t) {
            position += t * velocity;
        }
    }
    
    public class WheeledVehicle extends Vehicle {
       protected int wheelRadius;
       protected int wheelRPM;
    
        public void makeUsGo() {
             velocity += wheelRadius * wheelRPM - friction + blahmyphysicsisrustyblah;
        }
    }
    
    public interface PedalPowered {
         public void pedal(int rpm);
    }
    
    public class Bicycle extends WheeledVehicle implements PedalPowered {
         public void pedal(int rpm) {
              wheelRPM = rpm;
              makeUsGo();
         }
    }
    
    public class Person {
         public void pedal(PedalPowered transport) {
              transport.pedal(this.legStrength);
         }
    }
    

    Edit: Added a very, very important comment.
    gjaustin on
    Your belief is not required
  • JasconiusJasconius bird internet Saint Petersburg RussiaRegistered User regular
    if you dont want to do OOP then you're going to have serious career issues
  • Lt Muffin360Lt Muffin360 Registered User regular
    Jasconius speaks the truth. I did an experiment one time and I found a simple coding question online. I solved it using OOP in... well... I don't remember the OO language.

    I then solved the same problem with a functional language (ML I believe here).

    The difference? OO was about 10 lines of code. Super simple.

    The functional language required around 75 lines of code.

    If OOP is wrong, I don't want to be right.
    steam_sig.png
  • gavindelgavindel Registered User regular
    Thanks, @gjaustin.

    Its not that I don't want to do OOP. Its that I've never done it before, and I have terrible visions of setting the bank on fire with my terrible code.

    Okay, so perhaps a touch melodramatic.
    Aether drive online. Blogs, rants, gaming nerdity. http://www.aetherdrive.com
  • InfidelInfidel It's not Infidel, it's INNNNNFIDELRegistered User regular
    The stance you seem to be implying by the way is "I need to learn how to code first, I'll figure OOP out later!"

    Which is backwards and will potentially hurt your development.

    The biggest value in OOP is that you are breaking your design into logical pieces that transcend language specifics. When you think of the big picture and how things fit together, it is much easier to see the objects and how they should be implemented, and then you deal with your specific language and tasks.
    Play D&D 4e? :: Check out Orokos and upload your Character Builder sheet! :: Orokos Dice Roller
    The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
    Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
  • gjaustingjaustin Registered User regular
    gavindel wrote: »
    Thanks, @gjaustin.

    Its not that I don't want to do OOP. Its that I've never done it before, and I have terrible visions of setting the bank on fire with my terrible code.

    Okay, so perhaps a touch melodramatic.

    I fail to see the downside. Some banks deserve to be set on fire :)

    In the end, OOP is just a way to think about things and compare them.

    Are two things interacted with in the same way? Then they should share an interface.
    Do two things work the same way? Then they should share a base class.
    Your belief is not required
  • InfidelInfidel It's not Infidel, it's INNNNNFIDELRegistered User regular
    Also I wouldn't sweat it about the internship too much.

    Any reasonable place will assume you know shit and will have to be shown everything. You won't be given responsibility until you prove you can handle it, at which point they will be super happy at any small amount.
    Play D&D 4e? :: Check out Orokos and upload your Character Builder sheet! :: Orokos Dice Roller
    The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
    Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
  • EchoEcho Per Aspera Ad Inferi Super Moderator, Moderator mod
    edited May 2013
    Of course I find simpler, more elegant Josephus solution that's pretty obvious once you read it. No need to override the array accessor, I can just rotate X steps and then shift the first object out of the array and repeat as needed.

    edit: it's still awesome to override methods for one particular variable though. 8->
    def josephus(n, k)
      prisoners = (0...n).to_a
      prisoners.rotate!(k-1).shift while prisoners.length > 1
      return prisoners.first
    end
    
    Echo on
  • gavindelgavindel Registered User regular
    Let's step through some OOP and see how much I understand (hopefully not spamming the thread too much). Let's implement a book store.

    So a simple bookstore has a couple features: books, bookshelves, cash registers, attendants, overpriced local coffee shop. Books are organized on shelves by genre and name. They have a price, which is given to the cash register at check out. Attendants perform check out, search, and organize functions on books and bookshelves. Overpriced local coffee shop makes you feel morally superior to Starbucks.

    Book objects would come with ISBN, title, name, genre, prices. One method might access the text and another one select the book for purchase. If you look at inheritance, all books would have the same general information, but subtypes might include "illustrated children's books" that come with pictures as part of their type, or "books on sale" that modify price. Private information might be statistics like the number of sales or the distributor price.

    Bookshelves would have genres assigned to them. I suppose they would also keep track of the books moving in and out for stocking? But would that be a method or a variable? Books would be assigned to a shelf, and the shelf would keep track of their positions.

    Cash registers would use a method to total up all the book objects that are ready for purchase and remove the sold books from inventory.

    Attendants would access bookshelves to sort. They would add any books that were not purchased back to the shelves. Some attendants would not be accessible to the public (stockers, the manager) and have to be petitioned through the floor attendants. Manager subtypes would have additional methods.

    Overpriced local coffee shop would offer a +3 to the Smugness stat of the customer. (still more useful than cooking in WoW)

    We would set up interfaces in order to call the methods that belong to each object? So you might have an interface called "ShoppingCart" that tells the bookshelf to give over the book? Another one that harasses the attendant until they cry? The interface acts as the front that the customer sees and interacts with, an intermediary between them and the moving objects.

    The basic gist being that the back end of the bookstore is composed of objects poking objects, any of which can be reconfigured without changing the interface that the user sees at the front. They call "ShoppingCart" regardless of if its on bookshelf A or clearance rack B.
    Aether drive online. Blogs, rants, gaming nerdity. http://www.aetherdrive.com
  • DelduwathDelduwath Registered User regular
    Jasconius speaks the truth. I did an experiment one time and I found a simple coding question online. I solved it using OOP in... well... I don't remember the OO language.

    I then solved the same problem with a functional language (ML I believe here).

    The difference? OO was about 10 lines of code. Super simple.

    The functional language required around 75 lines of code.

    If OOP is wrong, I don't want to be right.

    I mean, like almost anything, this kind of depends on a lot of things. For example, what kind of problem are you solving? Imperative languages lend themselves well to some kinds of problems, and functional languages lend themselves well to others. Then there's the issue of how one writes code; when I started messing around with F#, I was writing some very C#-like F# code, and it didn't read or run well. Then I spent some time figuring out how to restructure my thinking and write F# code like F# code instead of C#-code-in-disguise, and it read and ran much better.

    I don't have a lot of practical experience with functional languages - really, just doing a bunch of Project Euler problems in F# - but there were some problems that were one-liners in F# and would have been baroque monstrosities in C#.

    Like anything, you want the right tool for the job. Chopping down a tree with a screwdriver is going to be tedious, no matter how good screwdrivers are at driving screws.
    weapon_rex.jpg
  • Lt Muffin360Lt Muffin360 Registered User regular
    Fair enough. It was one of the simpler problems from Project Euler though.
    steam_sig.png
  • DelduwathDelduwath Registered User regular
    Then it sounds like you didn't use enough SolutionFactoryFactoryFactories!
    weapon_rex.jpg
  • HonkHonk Registered User regular
    Coded a raytracing engine with moveable camera. Found out why it's not used for games!

    With ambient light and 30 polygons, 500px square res, it runs at 0.125 frames per second!
  • PhyphorPhyphor Registered User regular
    Now make it so that you run the rays spread across cores! And then make it so you're cache efficient!
  • HonkHonk Registered User regular
    Sounds like a challenge but that would probably impress my professor.

    I do have a good idea on how to use normal directions in order to implement backface culling though!
  • PhyphorPhyphor Registered User regular
    edited May 2013
    But that does seem pretty slow - 2 million rays/second, but ray/polygon intersection tests should be much much faster than that
    Phyphor on
  • KambingKambing Registered User regular
    I'm firmly in the functional programming camp, but in the interest of fairness, when people talk about conciseness of solutions to particular problems, typically things beyond "object-oriented vs. functional" are at play. Some examples:

    (1) Java is notoriously verbose. Some of this has to do with OOP but a lot of it also has to do with the choice of syntax and lack of language-conveniences (e.g., getters/setters as in C#).
    (2) OCaml, with respect to a functional language, is also notoriously verbose. Again this has to do with some syntactic choices, but also has a lot to do with its relatively impoverished standard library (when compared to, e.g., Haskell).

    While I think OO design generally over complicates programs in all the wrong ways, there are few (if any) languages that are not otherwise elegant enough to be able to "pin the problem" solely on OO.
    @TwitchTV, @Youtube: master-level zerg ladder/customs, commentary, and random miscellany.
  • SaerisSaeris Chronogestaltist Trinity, New MexicoRegistered User regular
    I think that inheritance encourages too-early abstraction, and leads to code that tries to solve too broad of a problem. The designers of Go seem to agree. OO design tends to over-emphasize the need to avoid similar-but-not-quite-duplicate code, when really what matters is writing code that clearly demonstrates the business requirements to anyone who reads it.

    Proponents of OOP will agree that, if the intent of a program is clear from the architecture of the source alone, without even referencing external documentation, then the code is dramatically easier to maintain and, if necessary, modify. But inheritance doesn't necessarily help toward that cause, and after all, encapsulation, delegation, and information hiding are not OOP-exclusive concepts.

    There's a time and place for OOP, and in my experience, the situations in which it's the most elegant solution will be fairly obvious. Don't try to force it onto everything. That was Java's largest mistake.
    Nlgya.png
  • Jimmy KingJimmy King Registered User regular
    gavindel wrote: »
    Let's step through some OOP and see how much I understand (hopefully not spamming the thread too much). Let's implement a book store.

    So a simple bookstore has a couple features: books, bookshelves, cash registers, attendants, overpriced local coffee shop. Books are organized on shelves by genre and name. They have a price, which is given to the cash register at check out. Attendants perform check out, search, and organize functions on books and bookshelves. Overpriced local coffee shop makes you feel morally superior to Starbucks.

    Book objects would come with ISBN, title, name, genre, prices. One method might access the text and another one select the book for purchase. If you look at inheritance, all books would have the same general information, but subtypes might include "illustrated children's books" that come with pictures as part of their type, or "books on sale" that modify price. Private information might be statistics like the number of sales or the distributor price.

    Bookshelves would have genres assigned to them. I suppose they would also keep track of the books moving in and out for stocking? But would that be a method or a variable? Books would be assigned to a shelf, and the shelf would keep track of their positions.

    Cash registers would use a method to total up all the book objects that are ready for purchase and remove the sold books from inventory.

    Attendants would access bookshelves to sort. They would add any books that were not purchased back to the shelves. Some attendants would not be accessible to the public (stockers, the manager) and have to be petitioned through the floor attendants. Manager subtypes would have additional methods.

    Overpriced local coffee shop would offer a +3 to the Smugness stat of the customer. (still more useful than cooking in WoW)

    We would set up interfaces in order to call the methods that belong to each object? So you might have an interface called "ShoppingCart" that tells the bookshelf to give over the book? Another one that harasses the attendant until they cry? The interface acts as the front that the customer sees and interacts with, an intermediary between them and the moving objects.

    The basic gist being that the back end of the bookstore is composed of objects poking objects, any of which can be reconfigured without changing the interface that the user sees at the front. They call "ShoppingCart" regardless of if its on bookshelf A or clearance rack B.
    That's more or less it. At a very high level, OOP is just about taking "things", figuring out what properties they have that you need to know about and what actions they take, and describing them in code. At a bit more technical there's a bunch of big, confusing sounding words for describing things that are actually super obvious once it clicks and basically boil down to namespacing and encapsulating data so that it's less likely to muck with other stuff and so that you don't care how things are implemented as long as they return the data you expect.

    A simple pseudo code (because I'm not typing out java when I don't absolutely have to) partial implementation of what you described might look like
    class Book {
    
        # type name
        string title
        Author author
        BookShelf bookshelf
        string isbn
    
       BookConstrucorMethod(title, author, bookshelf, isbn) {
            self.title = title
            self.author = author
            self.isbn = isbn
    
            # bookshelf might be optional... maybe its not on a shelf yet
            self.bookshelf = bookshelf
       }
    
    }
    
    class Author {
        string firstName
        string lastName
        Books[] books   #an array/list of books
    
        AuthorConstructorMethod(firstName, lastName) {
           self.firstName = firstName
           self.lastName = lastName
        }
    
       method writeBook(title, isbn) {
           book = new Book(title, self, null, isbn)
           self.books.append(book)
           return book
       }
    }
    
    class BookShelf {
        int shelfNumber
        Books[] books
        int maxBooks
    
        BookShelfConstructorMethod(number, maxbooks, currentBooks) {
           self.shelfNumber = number
           self.maxBooks = maxbooks
           self.books = currentBooks
        }
    
        method addBook(book) {
                self.books.append(book)
                book.bookshelf = self
        }
    
       method removeBook(book) {
           self.books.remove(book)  # totally taking advantage of pseudocode here... or maybe it's a hash/dict rather than list
           book.bookshelf = null
       }
    }
    
    So then your code would create an Author object, call Author.writeBook(title, isbn, etc) which would create a new Book object. Create a BookShelf object, call bookshelf.addBook(book), passing in the book you are putting on the shelf, to properly add a book to a shelf, etc. Actual specifics will all come down to what you need to do and the language's preferences - there are things that are considered 100% the right way to do things in Java that would cause Python and Ruby developers to stab you if you did it in their code, sometimes the "pure" OO way is actually way more verbose than what you are doing really needs (maybe for what you are doing right now it makes more sense to just directly create an instance of a Book rather than create an Author then call Author.writeBook(), etc), sometimes there are multiple ways to implement something that make sense (true for all code, not just OO) and so you just have to decide which one seems to be the best for the current situation and run with it.
    import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.stringreturners.StringStringReturner;
  • bowenbowen Registered User regular
    Phyphor wrote: »
    But that does seem pretty slow - 2 million rays/second, but ray/polygon intersection tests should be much much faster than that

    My friend used all the SSH clients in the labs as slaves for ray tracing when he was at school.

    I think he rendered something in about 5 minutes.
  • Jimmy KingJimmy King Registered User regular
    Any chance you guys know of a django user registration app like django-registration which supports the django 1.5 custom user model? I've been tinkering with django-registration code to make it work, but it's really a bit of a clusterfuck since it's based on code where the user was represented by a standard model which always had the same fields and now it could have any fields of any type, with anything representing the username, etc.

    Since I need this working sooner rather than later, I may have to just write my own one off registration system for this site, but I'm checking around just in case someone has already solved the problem.
    import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.stringreturners.StringStringReturner;
  • JasconiusJasconius bird internet Saint Petersburg RussiaRegistered User regular
    I don't see why you would need a custom module now that django supports custom user models to begin with

    that was like... the only reason you would use a registration module to begin with right?

  • Jimmy KingJimmy King Registered User regular
    django-registration is a simple app that handles registering new users - enter your email address, get an email with a link and unique code, follow the link, etc. resend e-mails if they never arrived, expire urls after a given time period, extensibility so that you can do stuff like have an admin have to ok an account before it's enabled, etc.

    The problem is that it foreign keys directly to django.contrib.auth.models.User, assumes that the User model will have a field called "username", that the username will just be a plain string, assumes there will be a field called email, a field called password, etc. User.objects.create_user() takes a username, email, and password as args and so django-registration assumes that when it calls it, in all of its forms, etc.

    The most common problem here is that the custom user model ditches the username field altogether, instead you use email for the login, set CustomUserModel.USERNAME_FIELD = 'email', write a custom model manager where create_user() and create_superuser() now take email and password args rather than username, email, and password args, etc. You can also have any number of other fields which can be made required or not required. Now nothing about django-registration works. Updating django-registration to use the new model is easy, but there's a lot more work involved in making it know to use the right username field, other required fields, fields you may have renamed, etc. and even more work in getting test cases to work because you can't hard code known good values for the test cases when there's no guarantee of what is known to be valid anymore.

    If I decide to keep up with it, I don't think it'll be too bad to make it work, and then for the test cases I may have default values it works with which assume django defaults and then just add a setting where you can override that stuff for your own user model if you need to. It's not undoable, just more work than I want to put into an a project which needs done soon and has a tiny budget when doing a one off project specific registration app will be quicker.
    import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.stringreturners.StringStringReturner;
  • zeenyzeeny Registered User regular
    edited May 2013
    Saeris wrote: »
    I think that inheritance encourages too-early abstraction, and leads to code that tries to solve too broad of a problem. The designers of Go seem to agree. OO design tends to over-emphasize the need to avoid similar-but-not-quite-duplicate code, when really what matters is writing code that clearly demonstrates the business requirements to anyone who reads it.

    Proponents of OOP will agree that, if the intent of a program is clear from the architecture of the source alone, without even referencing external documentation, then the code is dramatically easier to maintain and, if necessary, modify. But inheritance doesn't necessarily help toward that cause, and after all, encapsulation, delegation, and information hiding are not OOP-exclusive concepts.

    There's a time and place for OOP, and in my experience, the situations in which it's the most elegant solution will be fairly obvious. Don't try to force it onto everything. That was Java's largest mistake.

    Java's largest mistake was not saying "Fuck it! We'll go all the way." and doing immutable by design.

    Also, when are you pussies going to join the Clojure revolution? I'm just waiting on that first clojure job to appear... any second now. Job market will surely deliver.
    zeeny on
  • an_altan_alt Registered User regular
    There are three main programming paradigms you'll run into in the real world - imperative, functional, and OOP. There are a few others, but you might implement your event driven UI in OOP for example, so I'll just focus on these three.

    Imperative programming is usually what you'll see in legacy code. It reads like a novel from top to bottom and tells a story along the way. It's intuitive to write, but is generally a pain to modify or debug since things are too interconnected. It can be done better with more structure, but still has the same issues. This is usually how people get started on programming, but it doesn't scale well and has fallen out of favor.

    Functional programming is a completely different approach that starts with thinking about functions and transformations and is often used for math related fields. You want to add things, buy things, process things. In functional programming, you write your buy function then if you need to work with some other thing, you just put some code in the buy method to deal with that particular thing. There's usually a lack of state and mutability as well as passing around functions to other functions. It's really weird if you're not used to it, but makes sense for some applications.

    OOP is another way of thinking. As described by everyone else, it starts with the objects or the 'things'. Those things have their own data and their own methods - they know how to look after themselves. You ask for a new book and the book knows how to create itself. This leads to dealing with objects through an interface instead of implementation. You don't care how a book gets sold, but you call a method and it happens. If selling is changing one field of book or going through 20 parent classes, it doesn't matter to you.

    It's those last few features which make OOP so popular. Simple examples of OOP always seem verbose and silly because it's extra work for a simple situation. However, the bigger and more complicated the program gets, an imperative design becomes more difficult to change and debug. In an OOP design, changes are drastically easier and that's a main reason it's so popular.
    Pony wrote:
    I think that the internet has been for years on the path to creating what is essentially an electronic Necronomicon: A collection of blasphemous unrealities so perverse that to even glimpse at its contents, if but for a moment, is to irrevocably forfeit a portion of your sanity.
    Xbox - PearlBlueS0ul, Steam
  • JasconiusJasconius bird internet Saint Petersburg RussiaRegistered User regular
    Jimmy King wrote: »
    django-registration is a simple app that handles registering new users - enter your email address, get an email with a link and unique code, follow the link, etc. resend e-mails if they never arrived, expire urls after a given time period, extensibility so that you can do stuff like have an admin have to ok an account before it's enabled, etc.

    The problem is that it foreign keys directly to django.contrib.auth.models.User, assumes that the User model will have a field called "username", that the username will just be a plain string, assumes there will be a field called email, a field called password, etc. User.objects.create_user() takes a username, email, and password as args and so django-registration assumes that when it calls it, in all of its forms, etc.

    The most common problem here is that the custom user model ditches the username field altogether, instead you use email for the login, set CustomUserModel.USERNAME_FIELD = 'email', write a custom model manager where create_user() and create_superuser() now take email and password args rather than username, email, and password args, etc. You can also have any number of other fields which can be made required or not required. Now nothing about django-registration works. Updating django-registration to use the new model is easy, but there's a lot more work involved in making it know to use the right username field, other required fields, fields you may have renamed, etc. and even more work in getting test cases to work because you can't hard code known good values for the test cases when there's no guarantee of what is known to be valid anymore.

    If I decide to keep up with it, I don't think it'll be too bad to make it work, and then for the test cases I may have default values it works with which assume django defaults and then just add a setting where you can override that stuff for your own user model if you need to. It's not undoable, just more work than I want to put into an a project which needs done soon and has a tiny budget when doing a one off project specific registration app will be quicker.

    I don't think it will take long for a new one to emerge that supports this.

    You may want to see if the issue has been raised on the open source issue tracking... if so... make the changes!
  • Jimmy KingJimmy King Registered User regular
    edited May 2013
    Jasconius wrote: »
    Jimmy King wrote: »
    django-registration is a simple app that handles registering new users - enter your email address, get an email with a link and unique code, follow the link, etc. resend e-mails if they never arrived, expire urls after a given time period, extensibility so that you can do stuff like have an admin have to ok an account before it's enabled, etc.

    The problem is that it foreign keys directly to django.contrib.auth.models.User, assumes that the User model will have a field called "username", that the username will just be a plain string, assumes there will be a field called email, a field called password, etc. User.objects.create_user() takes a username, email, and password as args and so django-registration assumes that when it calls it, in all of its forms, etc.

    The most common problem here is that the custom user model ditches the username field altogether, instead you use email for the login, set CustomUserModel.USERNAME_FIELD = 'email', write a custom model manager where create_user() and create_superuser() now take email and password args rather than username, email, and password args, etc. You can also have any number of other fields which can be made required or not required. Now nothing about django-registration works. Updating django-registration to use the new model is easy, but there's a lot more work involved in making it know to use the right username field, other required fields, fields you may have renamed, etc. and even more work in getting test cases to work because you can't hard code known good values for the test cases when there's no guarantee of what is known to be valid anymore.

    If I decide to keep up with it, I don't think it'll be too bad to make it work, and then for the test cases I may have default values it works with which assume django defaults and then just add a setting where you can override that stuff for your own user model if you need to. It's not undoable, just more work than I want to put into an a project which needs done soon and has a tiny budget when doing a one off project specific registration app will be quicker.

    I don't think it will take long for a new one to emerge that supports this.

    You may want to see if the issue has been raised on the open source issue tracking... if so... make the changes!

    It has been brought up. Some people even did partial patches and submitted pull requests to the developer. He closed them back in March saying that he was going to do this during PyCon 2013 sprints and making some asshole-ish remarks about people not paying attention when he said that was his plan. Unfortunately those were also in March and he didn't do it and hasn't accepted anyone else's patches. I think he will get there, he has been doing other django 1.5 stuff, just nothing related to supporting the custom user models.

    What I've done for now is forked the official repo, made the obvious, simpler, non-breaking changes (which also don't fix much), etc. And then I'm writing a project specific app which is closely based on django-registration, after all, the code and process are already proven, there are just some parts that don't work. When changes I need to make are generic and don't obviously break something I'm making the same change on my django-registration fork. This way I can whip up exactly what I need without any worries about backwards compatibility, working with some other project, etc. but by the end will hopefully have made a good chunk of the changes django-registration needs while keeping it useable for other projects. If django-registration ever becomes fully 1.5 compatible I can hopefully also just swap it out with only minor changes to my project, if it makes sense to do so, such as to be using code that has more eyeballs on it.
    Jimmy King on
    import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.stringreturners.StringStringReturner;
  • rRootagearRootagea Registered User regular
    edited May 2013
    Are you allowed to use optix (ray tracing in parallel on nvidia gpus)? Its all I used in a introductory graphics course, ran the cornell box at 30 fps.

    Ultimately the point of programming paradigms is to allow you to reason as fluidly as possible. Sometimes it helps to group similar types under a broader base type. Sometimes it helps to group all functions that acts similarly, say importing data of a variety of types. In c#, if you have alot of transformations with intermediate steps, its super fun to go oops all extension methods.

    If you want to check out clojure, this is the video that got me. At this point its my preferred language, and I hear there might be jobs? soon?

    rRootagea on
  • JasconiusJasconius bird internet Saint Petersburg RussiaRegistered User regular
    Jimmy King wrote: »
    Jasconius wrote: »
    Jimmy King wrote: »
    django-registration is a simple app that handles registering new users - enter your email address, get an email with a link and unique code, follow the link, etc. resend e-mails if they never arrived, expire urls after a given time period, extensibility so that you can do stuff like have an admin have to ok an account before it's enabled, etc.

    The problem is that it foreign keys directly to django.contrib.auth.models.User, assumes that the User model will have a field called "username", that the username will just be a plain string, assumes there will be a field called email, a field called password, etc. User.objects.create_user() takes a username, email, and password as args and so django-registration assumes that when it calls it, in all of its forms, etc.

    The most common problem here is that the custom user model ditches the username field altogether, instead you use email for the login, set CustomUserModel.USERNAME_FIELD = 'email', write a custom model manager where create_user() and create_superuser() now take email and password args rather than username, email, and password args, etc. You can also have any number of other fields which can be made required or not required. Now nothing about django-registration works. Updating django-registration to use the new model is easy, but there's a lot more work involved in making it know to use the right username field, other required fields, fields you may have renamed, etc. and even more work in getting test cases to work because you can't hard code known good values for the test cases when there's no guarantee of what is known to be valid anymore.

    If I decide to keep up with it, I don't think it'll be too bad to make it work, and then for the test cases I may have default values it works with which assume django defaults and then just add a setting where you can override that stuff for your own user model if you need to. It's not undoable, just more work than I want to put into an a project which needs done soon and has a tiny budget when doing a one off project specific registration app will be quicker.

    I don't think it will take long for a new one to emerge that supports this.

    You may want to see if the issue has been raised on the open source issue tracking... if so... make the changes!

    It has been brought up. Some people even did partial patches and submitted pull requests to the developer. He closed them back in March saying that he was going to do this during PyCon 2013 sprints and making some asshole-ish remarks about people not paying attention when he said that was his plan.

    Sounds like all the old Rails people have moved on to Django

    pity
  • urahonkyurahonky Registered User regular
    Using the Eclipse debugger... Is it possible for it to have it stop doing it's thing when a particular expression occurs?

    Like say if I wanted it to stop what it's doing and notify me with a String contains the value "AFB" or something like that.
  • Jimmy KingJimmy King Registered User regular
    Jasconius wrote: »
    Jimmy King wrote: »
    Jasconius wrote: »
    Jimmy King wrote: »
    django-registration is a simple app that handles registering new users - enter your email address, get an email with a link and unique code, follow the link, etc. resend e-mails if they never arrived, expire urls after a given time period, extensibility so that you can do stuff like have an admin have to ok an account before it's enabled, etc.

    The problem is that it foreign keys directly to django.contrib.auth.models.User, assumes that the User model will have a field called "username", that the username will just be a plain string, assumes there will be a field called email, a field called password, etc. User.objects.create_user() takes a username, email, and password as args and so django-registration assumes that when it calls it, in all of its forms, etc.

    The most common problem here is that the custom user model ditches the username field altogether, instead you use email for the login, set CustomUserModel.USERNAME_FIELD = 'email', write a custom model manager where create_user() and create_superuser() now take email and password args rather than username, email, and password args, etc. You can also have any number of other fields which can be made required or not required. Now nothing about django-registration works. Updating django-registration to use the new model is easy, but there's a lot more work involved in making it know to use the right username field, other required fields, fields you may have renamed, etc. and even more work in getting test cases to work because you can't hard code known good values for the test cases when there's no guarantee of what is known to be valid anymore.

    If I decide to keep up with it, I don't think it'll be too bad to make it work, and then for the test cases I may have default values it works with which assume django defaults and then just add a setting where you can override that stuff for your own user model if you need to. It's not undoable, just more work than I want to put into an a project which needs done soon and has a tiny budget when doing a one off project specific registration app will be quicker.

    I don't think it will take long for a new one to emerge that supports this.

    You may want to see if the issue has been raised on the open source issue tracking... if so... make the changes!

    It has been brought up. Some people even did partial patches and submitted pull requests to the developer. He closed them back in March saying that he was going to do this during PyCon 2013 sprints and making some asshole-ish remarks about people not paying attention when he said that was his plan.

    Sounds like all the old Rails people have moved on to Django

    pity
    This guy is actually the release manager for Django at Lawrence Journal-World, where Django was created, probably been working on Django since day 1. I'm not sure what his deal is in this case.
    import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.stringreturners.StringStringReturner;
  • dobilaydobilay Registered User regular
    urahonky wrote: »
    Using the Eclipse debugger... Is it possible for it to have it stop doing it's thing when a particular expression occurs?

    Like say if I wanted it to stop what it's doing and notify me with a String contains the value "AFB" or something like that.

    Are you just looking to do this for a particular line or anywhere in the code?
  • gjaustingjaustin Registered User regular
    dobilay wrote: »
    urahonky wrote: »
    Using the Eclipse debugger... Is it possible for it to have it stop doing it's thing when a particular expression occurs?

    Like say if I wanted it to stop what it's doing and notify me with a String contains the value "AFB" or something like that.

    Are you just looking to do this for a particular line or anywhere in the code?

    Yeah, because for a specific line all you have to do is right-click on the breakpoint and select "Breakpoint Properties"
    Your belief is not required
  • InfidelInfidel It's not Infidel, it's INNNNNFIDELRegistered User regular
    dobilay wrote: »
    urahonky wrote: »
    Using the Eclipse debugger... Is it possible for it to have it stop doing it's thing when a particular expression occurs?

    Like say if I wanted it to stop what it's doing and notify me with a String contains the value "AFB" or something like that.

    Are you just looking to do this for a particular line or anywhere in the code?

    Yeah, you can do this for a breakpoint (see this) but I don't know of any means in Eclipse to have a global watch on a break condition.

    You'd have to setup the conditional on a breakpoint that is set on places where the value can change, hopefully it isn't many places and that is what you actually are trying to do?
    Play D&D 4e? :: Check out Orokos and upload your Character Builder sheet! :: Orokos Dice Roller
    The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
    Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
  • urahonkyurahonky Registered User regular
    Anywhere in the code... See I have a large, large, large blob of data coming in from a database. This turns into an ASObject which has a Map attached to it. I need to have it go through this huge chunk of code until I hit a specific string (I'm just trying to see if this is even getting populated correctly).
Sign In or Register to comment.