Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Can you code and should I learn to?

2

Comments

  • Closed Accounts Posts: 3,570 ✭✭✭Mint Aero


    It's very much a matter of if.


    Nope, when.


  • Registered Users, Registered Users 2 Posts: 13,080 ✭✭✭✭Maximus Alexander


    Mint Aero wrote: »
    Nope, when.

    Cool, since you're the time traveler you might as well put us out of our misery - when does it happen?


  • Closed Accounts Posts: 9,088 ✭✭✭SpaceTime


    Already here and trawling your email, texts, Facebook, credit cards etc to check you're not a terrorist most likely!


  • Registered Users, Registered Users 2 Posts: 9,453 ✭✭✭Shenshen


    Can't do a lot, some basic html and well, a bit of basic. All of it pretty much self-taught.

    Enough to be able to put together the odd macro in Excel and LibreOffice.
    But I've reached a point where I'd want to be able to do a bit more, just out of curiosity. Could anyone here recommend a good way to start? A good introductory book perhaps?


  • Closed Accounts Posts: 3,570 ✭✭✭Mint Aero


    Cool, since you're the time traveler you might as well put us out of our misery - when does it happen?

    Soon my dear Alexander, very soon.


  • Registered Users, Registered Users 2 Posts: 2,655 ✭✭✭draiochtanois


    This post has been deleted.


  • Registered Users, Registered Users 2 Posts: 1,794 ✭✭✭Aongus Von Bismarck


    I've been learning the R Programming language for the past number of months. It's extremely useful for taking data sets and applying statistical analysis to that data. It's not difficult to learn once you have a good grounding in statistics. I found learning the syntax to be fairly trivial.
    If children can learn to code then it should be easy for an adult to learn. It's computer programming we're talking about, not quantum physics or developing a new form of derivative trading instrument.


  • Registered Users, Registered Users 2 Posts: 81,220 ✭✭✭✭biko


    Should I, an old git learn
    As part of coding you will actually learn git.

    Dev forum has many good suggestions


  • Closed Accounts Posts: 9,088 ✭✭✭SpaceTime


    Biggest issue is the leaving cert had evolved into an exercise in regurgitation not problem solving or researching.

    I think that's where China will fall down too. Their system is even more extremely like that. Grind schools and learn by rote.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 13,080 ✭✭✭✭Maximus Alexander


    Shenshen wrote: »
    Can't do a lot, some basic html and well, a bit of basic. All of it pretty much self-taught.

    Enough to be able to put together the odd macro in Excel and LibreOffice.
    But I've reached a point where I'd want to be able to do a bit more, just out of curiosity. Could anyone here recommend a good way to start? A good introductory book perhaps?

    I bought this book in 2009 and now I work in software development. Oddly enough, not using Java. But... yeah. I'd recommend it as a starting point. ;)


  • Closed Accounts Posts: 5,857 ✭✭✭professore


    Not to mention that if we somehow got to the point that coding was automated then literally everything would be automated.

    If they come up with an app that can understand illogical, conflicting and ridiculous customer requirements - then that truly will be the end of programming. Until then our jobs are safe.

    Imagine - "Computer deduces that human manager is an idiot"


  • Closed Accounts Posts: 5,857 ✭✭✭professore


    SpaceTime wrote: »
    Biggest issue is the leaving cert had evolved into an exercise in regurgitation not problem solving or researching.

    I think that's where China will fall down too. Their system is even more extremely like that. Grind schools and learn by rote.

    Evolved?? It was far worse back in 1989 when I did it - in fact much more so than now, you had 50+ poems that you were asked specific questions about, so you had to know them all, and PEIG for a start. Now it's "Use a poem you've learned to illustrate your point".


  • Registered Users, Registered Users 2 Posts: 9,453 ✭✭✭Shenshen


    I bought this book in 2009 and now I work in software development. Oddly enough, not using Java. But... yeah. I'd recommend it as a starting point. ;)

    Cool, thanks. It's on my wish list now, the price requires a bit of economical preparation. :)


  • Registered Users, Registered Users 2 Posts: 11,817 ✭✭✭✭Charlie19


    Shenshen wrote: »
    Cool, thanks. It's on my wish list now, the price requires a bit of economical preparation. :)

    http://www.amazon.co.uk/gp/aw/ol/0132575663/ref=mw_dp_olp?ie=UTF8&condition=all


  • Registered Users, Registered Users 2 Posts: 24,439 ✭✭✭✭One eyed Jack


    Shenshen wrote: »
    Can't do a lot, some basic html and well, a bit of basic. All of it pretty much self-taught.

    Enough to be able to put together the odd macro in Excel and LibreOffice.
    But I've reached a point where I'd want to be able to do a bit more, just out of curiosity. Could anyone here recommend a good way to start? A good introductory book perhaps?


    http://coderdojo.ie/ is a good place to start if you'd like to learn the basics in your own time. They have sample programs and exercises you can try out.

    I've been learning the R Programming language for the past number of months. It's extremely useful for taking data sets and applying statistical analysis to that data. It's not difficult to learn once you have a good grounding in statistics. I found learning the syntax to be fairly trivial.
    If children can learn to code then it should be easy for an adult to learn. It's computer programming we're talking about, not quantum physics or developing a new form of derivative trading instrument.


    In my experience it's actually easier to teach children than adults, because adults have great difficulty in relating to some of the basic principles and concepts of software development, whereas children are much more open to experimentation and fixing things when they go wrong, whereas adults expect everything to work first time and get frustrated easily if it doesn't.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 43,028 ✭✭✭✭SEPT 23 1989


    keep feeding the machines information until they finally turn on us


  • Closed Accounts Posts: 20,373 ✭✭✭✭foggy_lad


    Back when we were still in school we were being told to be block layers/plasterers etc to feed the upcoming boom with cheap labour!


  • Registered Users, Registered Users 2 Posts: 13,080 ✭✭✭✭Maximus Alexander


    Shenshen wrote: »
    Cool, thanks. It's on my wish list now, the price requires a bit of economical preparation. :)

    It requires a bit of a time commitment too, but you don't need to read it cover to cover. The first few chapters are a great introduction and then you can kind of branch out on your own using web resources and dip back in to specific chapters when you need them.

    There are amazing resources on the web now, even compared to when I did it back in 09/10. Stackoverflow will be your friend. ;)

    Once you're comfortable in one language, it's fairly trivial to apply that to another one... and then another one... and another one... and... you get the idea.


  • Closed Accounts Posts: 9,088 ✭✭✭SpaceTime


    professore wrote: »
    Evolved?? It was far worse back in 1989 when I did it - in fact much more so than now, you had 50+ poems that you were asked specific questions about, so you had to know them all, and PEIG for a start. Now it's "Use a poem you've learned to illustrate your point".

    The world didn't start in 1989.
    The old LC course back in the 60s and 70s wasn't point pressurised and was a lot broader. The downside was that it was mostly taught by angry nuns and Christian bros who believed you could beat knowledge into someone using a type of binary coding system involving a big stick!


  • Moderators, Music Moderators, Society & Culture Moderators Posts: 25,734 Mod ✭✭✭✭Boom_Bap


    I dont have the letters BSc. after my name for nothing.

    printf("Hello World Boards"\n);


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 850 ✭✭✭Hans Bricks


    I picked a degree more geared toward Networking and databases (Cisco technology, SQL) but I do have a basic grasp of java. A lot of software engineering and development roles are currently sought after.

    It would be no harm to self teach yourself. For the likes of HTML, CSS, Javascript, JQuery etc. you could start here :

    http://www.w3schools.com/


  • Registered Users, Registered Users 2 Posts: 2,779 ✭✭✭Spunge


    Working in IT since 1999, never written a line of code. Try it, if you like writing code then it's for you, if you don't...it ain't. You really can't force it.

    Many of those people who started with me writing code are still writing code. I guess because they like it. My limited perspective says that money and promotion come from not knowing how to do anything technical but being able to talk a good game, i.e. Business Analyst > Pro Mgr > Managing More Stuff.

    In other words, if you are good at coding people like me (evil layabouts) will want you to continue coding so that you make us evil layabouts look good.

    Better to be able to talk about something rather than actually do it. At least within multinationals.

    That's the unkind truth from the coal face. I'm sure it's not universally true, but in my limited experience it is more often than not.

    can confirm, i dont talk a good game.


  • Registered Users, Registered Users 2 Posts: 12,035 ✭✭✭✭PopePalpatine


    In my experience it's actually easier to teach children than adults, because adults have great difficulty in relating to some of the basic principles and concepts of software development, whereas children are much more open to experimentation and fixing things when they go wrong, whereas adults expect everything to work first time and get frustrated easily if it doesn't.

    You hit the nail right on the head there Jack, I did no coding whatsoever before entering CSSE at NUI Maynooth in 2012, and from 2nd year onwards I started to falter whenever the lab sessions deviated from the stuff from the lectures. 13 years of rote learning did **** all to help in that regard, and sometimes you just don't know where to begin looking for help.


  • Registered Users, Registered Users 2 Posts: 1,312 ✭✭✭Paramite Pie


    I know HTML and CSS but as someone else mentioned it's not really code, just markup.
    fxotoole wrote: »
    Yup. And everyone needs to know Chinese because the Chinese are going to win world war 3 apparently

    胜利最辉煌的中国


  • Registered Users, Registered Users 2 Posts: 13,080 ✭✭✭✭Maximus Alexander


    Boom_Bap wrote: »
    I dont have the letters BSc. after my name for nothing.

    printf("Hello World Boards"\n);
    main.cpp:7:4: error: stray '\' in program                                                                                                                                                                                                              
        printf("Hello Boards"\n);                                                                                                                                                                                                                           
        ^
    


  • Registered Users, Registered Users 2 Posts: 14,329 ✭✭✭✭Cienciano


    murpho999 wrote: »
    Your right their.

    The amount of mistakes you see nowadays on the internet is shocking and makes me loose my mind.

    What sort of grammer their teaching kids at there schools nowadays.?
    Shocking.

    The amount of people that complain about bad grammar and spell "grammar" wrong is scary. "loose v lose" is another one that annoys a lot of people.
    Sort of ironic now that I quoted your post to say that I find people who point out spelling/grammar errors far more annoying. People might be on a phone, might have dyslexic, english mightn't be their first language, they might have their ' key broken like me so sometimes it doesnt register, they might be in a rush, they might just not care.


  • Moderators, Music Moderators, Society & Culture Moderators Posts: 25,734 Mod ✭✭✭✭Boom_Bap


    main.cpp:7:4: error: stray '\' in program                                                                                                                                                                                                              
        printf("Hello Boards"\n);                                                                                                                                                                                                                           
        ^
    

    B*llox, 5 years of 3rd level education out the window.


  • Registered Users, Registered Users 2 Posts: 22,407 ✭✭✭✭endacl


    Green Mile wrote: »
    I’ll be crucified for saying this but our youth would benefit more by learning code in school as oppose to Irish

    Why not both? Everything is so binary these days....

    :pac:


  • Registered Users, Registered Users 2 Posts: 2,328 ✭✭✭Magico Gonzalez


    Spunge wrote: »
    can confirm, i dont talk a good game.

    Quiet nerd ! Return to your work station and continue doing stuff.

    Can't get the staff, I swear..


  • Registered Users, Registered Users 2 Posts: 910 ✭✭✭rick_fantastic


    Can I code... Yes...

    Would I do it for a living... Not a chance in hell...

    I use the skill when I need to but I couldn't do it for a living, day in day out... That's what the code monkeys are for :D

    I much prefer to design something and get someone else to do the boring part while I move onto more exciting things.. and drop in to check on sprints and general functionality as it is delivered.

    Will I teach my kids to code from a young age... Definitely...


  • Advertisement
  • Closed Accounts Posts: 9,088 ✭✭✭SpaceTime


    You hit the nail right on the head there Jack, I did no coding whatsoever before entering CSSE at NUI Maynooth in 2012, and from 2nd year onwards I started to falter whenever the lab sessions deviated from the stuff from the lectures. 13 years of rote learning did **** all to help in that regard, and sometimes you just don't know where to begin looking for help.

    I know that feeling! Hit coding for the first time in a postgrad scenario and often I was just totally lost in labs! It got very humiliating after few months and I just abandoned the course.

    There was one day where we'd a class consisting of a guy going through code line by line for two hours. I came out of it giggling as I was so completely lost. I just went down to the fees office and handed in my notice of withdrawal.

    Biggest waste of time and money ever! I literally learnt nothing and spent my entire time stressed out, frustrated and being told by other students that I obviously wasn't putting the work in!


  • Registered Users, Registered Users 2 Posts: 20,193 ✭✭✭✭jimgoose


    I can code. I've been coding for nearly thirty years at this stage, for a living for fifteen or so. Mind you, I don't do as much coding as I'd like these days.


  • Registered Users, Registered Users 2 Posts: 81,220 ✭✭✭✭biko


    All you need to know:

    000100 IDENTIFICATION DIVISION.
    000200 PROGRAM-ID. HELLOWORLD.
    000300
    000400*
    000500 ENVIRONMENT DIVISION.
    000600 CONFIGURATION SECTION.
    000700 SOURCE-COMPUTER. RM-COBOL.
    000800 OBJECT-COMPUTER. RM-COBOL.
    000900
    001000 DATA DIVISION.
    001100 FILE SECTION.
    001200
    100000 PROCEDURE DIVISION.
    100100
    100200 MAIN-LOGIC SECTION.
    100300 BEGIN.
    100400 DISPLAY " " LINE 1 POSITION 1 ERASE EOS.
    100500 DISPLAY "Hello world!" LINE 15 POSITION 10.
    100600 STOP RUN.
    100700 MAIN-LOGIC-EXIT.
    100800 EXIT.


  • Registered Users, Registered Users 2 Posts: 13,080 ✭✭✭✭Maximus Alexander


    biko wrote: »
    All you need to know:

    000100 IDENTIFICATION DIVISION.
    000200 PROGRAM-ID. HELLOWORLD.
    000300
    000400*
    000500 ENVIRONMENT DIVISION.
    000600 CONFIGURATION SECTION.
    000700 SOURCE-COMPUTER. RM-COBOL.
    000800 OBJECT-COMPUTER. RM-COBOL.
    000900
    001000 DATA DIVISION.
    001100 FILE SECTION.
    001200
    100000 PROCEDURE DIVISION.
    100100
    100200 MAIN-LOGIC SECTION.
    100300 BEGIN.
    100400 DISPLAY " " LINE 1 POSITION 1 ERASE EOS.
    100500 DISPLAY "Hello world!" LINE 15 POSITION 10.
    100600 STOP RUN.
    100700 MAIN-LOGIC-EXIT.
    100800 EXIT.

    My brains. All over the wall.

    Object oriented or bust.


  • Moderators, Music Moderators, Society & Culture Moderators Posts: 25,734 Mod ✭✭✭✭Boom_Bap


    Is it still a case that there are massive consultancy rates for COBOL developers?


  • Registered Users, Registered Users 2 Posts: 81,220 ✭✭✭✭biko


    Yeah, COBOL is still the base for many banks and other financial institutions.


  • Closed Accounts Posts: 3,553 ✭✭✭Tarzana2


    If children can learn to code then it should be easy for an adult to learn.

    Adults can learn to code, but it would be easier to do it in childhood, when the brain soaks up information, like with languages.


  • Registered Users, Registered Users 2 Posts: 9,487 ✭✭✭banquo


    Web Developer wanted.

    We're not really sure how that whole side of things works, but just to be sure the applicant must have forty years experience in:

    Html 5.0
    CSS
    Web 2.0
    Javascript
    Angular Node JS 2.0 things
    Ajax
    jQuery
    Java
    Oracle
    PHP Version 5.4 and up
    Apache
    MySQL
    Mongo DB
    iOS Development
    xCode
    Ruby
    Adobe Creative Suite
    Quark
    CorelDraw

    And 5 years minimum in Swift development.

    You will be copy and pasting posts into our Wordpress site.

    Salary: 22k + two biscuits for supper.

    You can tell from the listing that we haven't a breeze what it is we want or realistically expect you to do. Job is based in an industrial estate in the middle of bloody nowhere and isn't on any maps."

    First day: "Can you set up email on my phone?" "Eh, I could if you weren't running Outlook 2002 or something." "Pfft, some tech guy!"


  • Closed Accounts Posts: 5,191 ✭✭✭Eugene Norman


    Can I code... Yes...

    Would I do it for a living... Not a chance in hell...

    I use the skill when I need to but I couldn't do it for a living, day in day out... That's what the code monkeys are for :D

    I much prefer to design something and get someone else to do the boring part while I move onto more exciting things.. and drop in to check on sprints and general functionality as it is delivered.

    Will I teach my kids to code from a young age... Definitely...

    When the cull comes the non technical PMs are first against the wall.

    Nobody should be in the business unless technical. I don't code much but I am an architect and when needs be I do lots.


  • Advertisement
  • Closed Accounts Posts: 5,191 ✭✭✭Eugene Norman


    Liquidrain wrote: »
    Adults are actually better than children at learning languages.

    I don't know if it's that kind of language.


  • Closed Accounts Posts: 3,553 ✭✭✭Tarzana2


    Liquidrain wrote: »
    Adults are actually better than children at learning languages.

    Adults might be better at sitting down to learn it, but that's not the same as soaking it up like young children do. Basically, it's a lot less effort for young children to learn languages. They don't need to put in anywhere near the effort an adult would.


  • Registered Users, Registered Users 2 Posts: 464 ✭✭The Th!ng


    I bought a second-hand 48K ZX Spectrum in the mid 1980's for £200. At first all I used it for was playing games, then I started programming it in BASIC - nothing too fancy, just for-next loops to plot pixels, draw circles and change the colour of the screen, etc. Later on I was given an assembler and a book on Z80 machine code. It took me ages to get my head around binary and hexadecimal, but with a bit of patience I finally understood what was going on. I have been programming as a hobby ever since and I think it'll be a good pasttime to keep my mind active when I retire. The only area of development that interests me at all is videogames and up to a few years ago I was using C# and XNA until Microsoft in their infinite wisdom decided to no longer update the framework. Recently I discovered App Game Kit which allows coders to develop games for mobile phones and tablets in BASIC.


  • Registered Users, Registered Users 2 Posts: 13,080 ✭✭✭✭Maximus Alexander


    The Th!ng wrote: »
    The only area of development that interests me at all is videogames and up to a few years ago I was using C# and XNA until Microsoft in their infinite wisdom decided to no longer update the framework. Recently I discovered App Game Kit which allows coders to develop games for mobile phones and tablets in BASIC.

    If you haven't yet, take a look at Unity. It's a free and fully featured game engine with scripting in C# (which you're obviously familiar with). Can deploy to multiple platforms. You might have some fun with it.


  • Registered Users, Registered Users 2 Posts: 1,465 ✭✭✭Anesthetize


    retalivity wrote: »
    Learn SQL and some UNIX scripting, be grand
    These two and PHP + HTML, you'll be fine and dandy. I've been coding in Java for the past 10 years but in the past year I've been using Bash for most stuff.


  • Registered Users, Registered Users 2 Posts: 1,597 ✭✭✭Totofan99




  • Advertisement
  • Registered Users, Registered Users 2 Posts: 464 ✭✭The Th!ng


    If you haven't yet, take a look at Unity. It's a free and fully featured game engine with scripting in C# (which you're obviously familiar with). Can deploy to multiple platforms. You might have some fun with it.

    Thanks Maximus, I have been meaning to take a look at Unity. By coincidence I was reading down through this subreddit last night when I spotted Paradox 3D, another cross platform C# framework.

    Whilst we're on the subject of coding you might want to have a look at POV-Ray, it's a freeware raytracer that uses a programming syntax to create the raytraced images.


  • Closed Accounts Posts: 2,894 ✭✭✭UCDVet


    As a full time software engineer / holder of two degrees in Computer Science....learning to code is a huge waste of time for nearly everyone.

    If you find it interesting and want to give it a shot. Go for it. But it's just a hobby, like reading comics or playing WoW. It's not going to make you a better person.

    If you are interested in doing it professionally, sure. Then it's useful and you can make a good living.

    But if you just enjoy using your PC/laptop/iPad/whatever - there is nothing to be gained. You'd be much better off taking a generic 'Intro to Windows' or 'Intro to Linux' type course.


  • Registered Users, Registered Users 2 Posts: 216 ✭✭AnLonDubh


    Shenshen wrote: »
    Can't do a lot, some basic html and well, a bit of basic. All of it pretty much self-taught.

    Enough to be able to put together the odd macro in Excel and LibreOffice.
    But I've reached a point where I'd want to be able to do a bit more, just out of curiosity. Could anyone here recommend a good way to start? A good introductory book perhaps?
    I would recommend Beginning Visual Basic 2012 by Brian Newsome, it teaches VB.Net which is essentially the big brother of VBA, the language you would use in Excel macros, so parts of it will be familiar. Also it's a beginner friendly language.


  • Registered Users, Registered Users 2 Posts: 156 ✭✭Depraved


    OP...if this looks like fun, then go ahead and take a course in Java.
    package Solution;
    
    
    import java.io.File;
    import java.lang.reflect.Method;
    import java.util.Arrays;
    import java.util.Collection;
    import java.util.HashSet;
    import java.util.Scanner;
    import java.util.TreeSet;
    
    public class UnsortedSetTest {
    
        public static void main(String[] args) throws Exception {
            String[] allFileNames = {"hounds.txt", "huckfinn.txt", "oz.txt", "war.txt", "ciaFactBook2008.txt"};
            String[] noCIA = {"hounds.txt", "huckfinn.txt", "oz.txt", "war.txt"};
            countWords(new BinarySearchTree<String>(), allFileNames[0]);
            for(String s : allFileNames) {
                System.out.println(s);
                countWordsOurUnsortedSet(s);
                countWordsOurBinarySearchTree(s);
                countWordsOurHash(s);
                countWordsCollection(new TreeSet<String>(), s);
                int[] result = countWordsCollection(new HashSet<String>(), s);
                System.out.println(result[0] + " total words.");
                System.out.println(result[1] + " distinct words.");
                System.out.println();
                
            }
        }
        
        // return total num words, and num distinct words
        public static int[] countWordsCollection(Collection<String> c, String fileName) throws Exception{
            c.clear();
            Scanner fileScanner = new Scanner(new File(fileName));  
            Stopwatch st = new Stopwatch();
            st.start();
            int total = 0;
            while(fileScanner.hasNext()){
                c.add(fileScanner.next());
                total++;
            }
            st.stop();
            System.out.println("Time for " + c.getClass() + " : \n" + st);
    //        System.out.println(c.size() + " distinct words");
    //        System.out.println(total + " total words including duplicates: ");
            assert total >= c.size();
            System.out.println();
            return new int[]{total, c.size()};
        }
        
        
        // GACKY GACKY GACKY repition. Look into removing repetition with reflection
        // we assume there will be add and size methods
        public static int[] countWordsOurHash(String fileName) throws Exception {
            Scanner fileScanner = new Scanner(new File(fileName));  
            Stopwatch st = new Stopwatch();
            UnsortedHashSet<String> c = new UnsortedHashSet<String>();
            st.start();
            int total = 0;
            while(fileScanner.hasNext()) {
                c.add(fileScanner.next());
                total++;
            }
            st.stop();
            System.out.println("Time for our hashtable (closed address hashing): \n" + st);
    //        System.out.println(c.size() + " distinct words");
    //        System.out.println(total + " total words including duplicates: ");
            assert total >= c.size();
            System.out.println();
            return new int[]{total, c.size()};
        }
        
        public static int[] countWordsOurUnsortedSet(String fileName) throws Exception {
            Scanner fileScanner = new Scanner(new File(fileName));  
            Stopwatch st = new Stopwatch();
            UnsortedSet<String> c = new UnsortedSet<String>();
            st.start();
            int total = 0;
            while(fileScanner.hasNext()){
                c.add(fileScanner.next());
                total++;
            }
            st.stop();
            System.out.println("Time for our unsorted set based on ArrayList: \n" + st);
    //        System.out.println(c.size() + " distinct words");
    //        System.out.println(total + " total words including duplicates: ");
            assert total >= c.size();
            System.out.println();
            return new int[]{total, c.size()};
        }
        
        public static int[] countWordsOurBinarySearchTree(String fileName) throws Exception {
            Scanner fileScanner = new Scanner(new File(fileName));  
            Stopwatch st = new Stopwatch();
            BinarySearchTree<String> c = new BinarySearchTree<String>();
            st.start();
            int total = 0;
            while(fileScanner.hasNext()){
                c.add(fileScanner.next());
                total++;
            }
            st.stop();
            System.out.println("Time for our binary search tree: \n" + st);
    //        System.out.println(c.size() + " distinct words");
    //        System.out.println(total + " total words including duplicates: ");
            assert total >= c.size();
            System.out.println();
            return new int[]{total, c.size()};
        }
        
        
        // a try at reflection. Not working on Binary Search tree from class. 
        // Hunch. Due to add method taking in Comparable, not Object!
        // Alterantives: search list of methods for name?
        public static int[] countWords(Object c, String fileName) throws Exception {
            Scanner fileScanner = new Scanner(new File(fileName));  
            Stopwatch st = new Stopwatch();
            System.out.println(Arrays.toString(c.getClass().getMethods()));
            Method addMethod = c.getClass().getMethod("add", Object.class);
            st.start();
            int total = 0;
            while(fileScanner.hasNext()){
                addMethod.invoke(c, fileScanner.next());
                total++;
            }
            st.stop();
            System.out.println("Time for " + c.getClass() + ": "+ st);
            Method sizeMethod = c.getClass().getMethod("size");
            int distictWords = (Integer) sizeMethod.invoke(c);
    //        System.out.println(distictWords + " distinct words");
    //        System.out.println(total + " total words including duplicates: ");
            System.out.println();
            return new int[]{total, distictWords};
        }
    }
    
    


  • Registered Users, Registered Users 2 Posts: 1,000 ✭✭✭fizzypish


    Languages are just tools. If you want to make something and you need a tool. Walking into an interview and saying I know X is all well and good but more than likely you'll then be asked what you used it for. I work in a field where its necessary for me to do some coding but I've never just went and learned a language. I was given a task and learned what I needed to accomplish said task. I'm not sure anybody in "coding" jobs are employed because they know X language (Bar the example of knowing an outdated language that some company has invested in too heavily to drop). They get work because they can solve problems.


  • Advertisement
Advertisement