Bad Textbook



  • The textbook for both my "Object Orented Programming With C++" class and my data structures and algorithms class were both written by the same author. 

     

    In the object oriented class he explained composition and inheritence by saying that one is an "is a relationship" and the other is a " has a relationship, but then in the first homework asignment after that we were supposed to derive a circle from the point class. 

    In the data structures and algorithms class one of the examples where he created an EmployeeLinkedList class that looked almost exactly the same as a Coding Horror.

     This is the n queens example he made:

     

    //Header file: stackADT.h
    
    #ifndef H_queueADT
    #define H_queueADT
      
    //*************************************************************
    // Author: D.S. Malik
    //
    // This class specifies the basic operations on a queue.
    //*************************************************************
    
    template <class Type>
    class queueADT
    {
    public:
        virtual bool isEmptyQueue() const = 0;
          //Function to determine whether the queue is empty.
          //Postcondition: Returns true if the queue is empty,
          //    otherwise returns false.
    
        virtual bool isFullQueue() const = 0;
          //Function to determine whether the queue is full.
          //Postcondition: Returns true if the queue is full,
          //    otherwise returns false.
    
        virtual void initializeQueue() = 0;
          //Function to initialize the queue to an empty state.
          //Postcondition: The queue is empty
    
        virtual Type front() const = 0;
          //Function to return the first element of the queue.
          //Precondition: The queue exists and is not empty.
          //Postcondition: If the queue is empty, the program 
          //    terminates; otherwise, the first element of the queue
          //    is returned.  
    
        virtual Type back() const = 0;
          //Function to return the last element of the queue.
          //Precondition: The queue exists and is not empty.
          //Postcondition: If the queue is empty, the program 
          //    terminates; otherwise, the last element of the queue
          //    is returned.
    
        virtual void addQueue(const Type& queueElement) = 0;
          //Function to add queueElement to the queue.
          //Precondition: The queue exists and is not full.
          //Postcondition: The queue is changed and queueElement is 
          //    added to the queue.
    
        virtual void deleteQueue() = 0;
          //Function to remove the first element of the queue.
          //Precondition: The queue exists and is not empty.
          //Postcondition: The queue is changed and the first element
          //    is removed from the queue.
    };
    
            
    #endif
    
    #include <iostream>
    #include <cmath>
    #include "nQueenPuzzle.h"
     
    using namespace std;
    
    nQueensPuzzle::nQueensPuzzle()
    {
    	noOfQueens = 8;
    	queensInColumn = new int[8];
    	noOfSolutions = 0;
    }
    
    nQueensPuzzle::nQueensPuzzle(int queens)
    {
    	noOfQueens = queens;
    	queensInColumn = new int[noOfQueens];
    	noOfSolutions = 0;
    }
    
    bool nQueensPuzzle::canPlaceQueen(int k, int i)
    {
    	for(int j = 0; j < k; j++)
    		if((queensInColumn[j] == i)
    			|| (abs(queensInColumn[j] - i) == abs(j-k)))
    			return false;
    	return true;
    }
    
    void nQueensPuzzle::queensConfiguration(int k)//, int queens)
    {
    	for(int i = 0; i < noOfQueens; i++)
    	{
    		if(canPlaceQueen(k, i))
    		{
    			queensInColumn[k] = i;
    			if(k == noOfQueens - 1)
    				printConfiguration();
    			else
    				queensConfiguration(k + 1);
    		}
    	}
    }
    
    void nQueensPuzzle::printConfiguration()
    {
    	noOfSolutions++;
    	cout<<"(";
    	for(int i = 0; i < noOfQueens - 1; i++)
    		cout<<queensInColumn[i]<<", ";
    
    
    	cout<<queensInColumn[noOfQueens - 1]<<")"<<endl;
    }
    
    int nQueensPuzzle::solutionsCount()
    {
    	return noOfSolutions;
    }
     

    One of the examples reminded me of the first time I deceded that that my one main method "programs" wasn't right. I had a vaugue idea that it needed more functions so I rewrote it, then realized that It was basically exacly the same becuase I was just passing all the data from function to function. 

    One example looked like

    initialize some variables

     calculations to assign them values

    initiaze another variable

    print the previous values

    calculations invovling the next variable.

     

    I feel sorry for students who haven't read any other books so that they have anything to compare this to. 

    I kept wondering if the ijk variables and wierd interfaces and logic explained why he needed to make the text so fluffy and repetitive.

     



  • TRWTF is teaching C++ to students in 2013.



  • How are we supposed to prove that we can use pointers and recusion?



  • @Chame1eon said:

    How are we supposed to prove that we can use pointers and recusion?

     

    I think Go has those.

     



  • @Chame1eon said:

    How are we supposed to prove that we can use pointers and recusion?

     

    Because obviously no other language has these.


     



  • @BC_Programmer said:

    @Chame1eon said:

    How are we supposed to prove that we can use pointers and recusion?

     

     

    Because obviously no other language has these.


     

     

    I was half kidding.  I'm not actually sure why they seem to test this ability for jobs that don't require it.  

    More seriously I actually liked the c++ primer becuase they mentioned described everything (lvalues integrals etc) that Java books seem to skim over.  

    I thought c and python might make more sense. c has low level stuff in more detail and python is very expressive and simple, but has functional features and objects.

     

    After I started reading that I started reading similar chapters in the c++ primer instead.  I tried the same with Intro to Algorithms but they were not similar enough.



  • @Chame1eon said:

    I thought c and python might make more sense. c has low level stuff in more detail and python is very expressive and simple, but has functional features and objects.

    If it was up to me, colleges would teach assembly, C, C# and Javascript, to give a full range of experience. They'd also teach stuff like SQL, VCS, automated testing, documentation and working on a software engineering team.



  • @morbiuswilters said:

    @Chame1eon said:
    I thought c and python might make more sense. c has low level stuff in more detail and python is very expressive and simple, but has functional features and objects.

    If it was up to me, colleges would teach assembly, C, C# and Javascript, to give a full range of experience. They'd also teach stuff like SQL, VCS, automated testing, documentation and working on a software engineering team.

     

    I've looked at the assembler produced by c compilers and in debuggers while reading buffer overflow articles and I seem to know about as much about x86 as MIPS which was covered in one of my classes, but I don't know why I would want to know more.  I can't think of any way to manipulate anything at that level.

     

    Do you mind explaining more about this?



  • @morbiuswilters said:

    If it was up to me, colleges would teach assembly, C, C# and Javascript, to give a full range of experience. They'd also teach stuff like SQL, VCS, automated testing, documentation and working on a software engineering team.

    If I had my way, incoming freshmen would play Rocky's Boots for the Commodore 64 (not that shitty Apple ][) until they could beat every challenge, then read "The Way Things Work", the chapter on how to build a computer out of half-adders, then skip directly to memory-managed languages (probably C#) with a gigantic warning to never use a non-managed language unless you had no alternative.

    Plus everything in Morbs' second sentence there. The SQL/data storage philosophy class I took was the only thing of use I got from my university career.



  • @morbiuswilters said:

    If it was up to me, colleges would teach assembly, C, C# and Javascript, to give a full range of experience. They'd also teach stuff like SQL, VCS, automated testing, documentation and working on a software engineering team.

    My university has classes on all of those (except C#, Java instead), all in the first or second year to give you a basic understanding of software engineering. They don't all have those?



  • @Chame1eon said:

    ...and I seem to know about as much about x86 as MIPS which was covered in one of my classes...

    It seems you learned assembly, then, right?

    @Chame1eon said:

    Do you mind explaining more about this?

    I think it's useful to understand how higher-level languages are translated into machine instructions.



  • @dtech said:

    They don't all have those?

    HA HA HA HA HA HA.



  • @blakeyrat said:

    Rocky's Boots

    I had a game for DOS sorta like that. You had to wire up robots using logic gates, and make them complete tasks for you. Also, it was set in some hellish future where robots ruled the world and would kill you on-sight, so you had to use your robot creations to hide you.

    Edit: Holy crap, I was able to find it easily on Google: Robot Odyssey. Apparently it was made by the same company that made Rocky's Boots and it used the same game engine.



  • @morbiuswilters said:

    @Chame1eon said:
    ...and I seem to know about as much about x86 as MIPS which was covered in one of my classes...

    It seems you learned assembly, then, right?

    I can read sections of it with a reference card. So..

    @Chame1eon said:

    Do you mind explaining more about this?

    I think it's useful to understand how higher-level languages are translated into machine instructions.

     

    I meant the list of languages. Is it becuase the languages themselves are useful or is it becuase they would be ideal for learning certain concepts or features in the general sense. 

    Javascript seems kind of annoying to me and I don't know of any unique abilities that I would want, but it's useful.

     




  • @Chame1eon said:

    both written by the same author
    Herbert Schildt? Yashwant Kanetkar?



  • @PJH said:

    @Chame1eon said:
    both written by the same author
    Herbert Schildt? Yashwant Kanetkar?
     

    John McAfee.



  • @Chame1eon: I never really spent any real time learning Assembly or C so I can't comment.

    But C# is the best Statically Typed Language out there. The framework is for the most part is well designed.

    SQL and understanding at least 3rd normal form is pretty important if you are doing any database work (which is pretty much a given if you are doing business applications). I am not amazing with databases, but I can usually do a decent job if I am required to create one for web app.

    JavaScript is one of those languages that is extremely expressive, but unless you know what you are doing you are probably creating a WTF in the process. I had a really hard time getting my head around it until I read JavaScript Patterns.



  • @lucas said:

    @Chame1eon:

     

    Does this HONESTLY look like Twitter to you?  Jesus Marion Christ, social networks are ruining pure-topic discussion forums.

     



  • @Chame1eon said:

    Is it becuase the languages themselves are useful or is it becuase they would be ideal for learning certain concepts or features in the general sense.

    Both. C is the grandfather to so many modern languages, and C is still used so widely. It forms the basis of practically every OS in existence. And understanding fundamental C concepts can help you understand things that the OS provides, like file systems, memory management, networking.

    C# is a good example of a modern, high-level, strictly-OO, class-based language. It's in the same vein as Java, although with fewer rough edges. Most development is done in Java or C#, and if you already know one you have a leg up on learning the other. Learning either is going to be a big benefit for finding employment.

    JS is almost on the opposite end of the spectrum from C#. It has a different OO paradigm, being prototype-based instead of class-based. There are few prototypal languages out there and I think learning the fundamentals not only broadens your horizons, it helps you understand class-based OO better, too. Also, JS is a very, very dynamic language with many unique features, such as closures. It's a great way to get exposure to dynamic programming, and to learn both its benefits and pitfalls. Also, JS is used in a lot of development nowadays, so it's a useful job skill.



  • @PJH said:

    @Chame1eon said:
    both written by the same author
    Herbert Schildt? Yashwant Kanetkar?

    The Deitels. (Actually, their books are really good.)


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.