Presentation is loading. Please wait.

Presentation is loading. Please wait.

Finding and using code online

Similar presentations


Presentation on theme: "Finding and using code online"— Presentation transcript:

1 Finding and using code online
Workshop

2 Goal for today Discuss Then practice
Looking for code online that you can use in your programs By the of the lecture you’ve gotten enough ideas that you’ll be able to find and use code on your own

3 Exploration Finding (and using) code that’s available online is an exploratory activity This can’t be ‘scripted’ Unlike, say, me showing you how to use a particular language feature

4 How to approach this You’re not aiming to understand the nitty-gritty details of how the code works Instead, get an overall understanding of how it works, the advantages and limitations of the algorithm Focus on the API I.e., what objects does it provide, which methods to call, etc

5 Abstract / Mental Stuff to look for
1-Sentence summary Make sure to explain the problem that the algorithm solves. Also explain how it compares to other algorithms, in a couple quick sentences. In a nutshell, why would anybody want to want to use it Properties of the algorithm Running time -Min, avg., max time Space required Limitations and Strengths Boundary conditions: single element array, etc.

6 Concrete Stuff to look for
Visualizations for the underlying algorithm Try to find code for the given algorithm Quality of docs? Ideally you should be able to compile + run it without (many) problems Github.com is a great place to look Sometimes there will be online demos (particularly for JS) Search for “_______ tutorial” How much activity / support does it have?

7 Let’s brainstorm! Let’s come up with a list of stuff to try in order to understand some code that exists

8 Let’s start by looking at the same alg/code:
C#’s built-in hashtable (it’s named “Dictionary”) NOTE: This is a link to the ‘.Net Core’ version – there’s also a version for the ‘.Net Framework’, too It’s pretty well-documented ‘Remarks’ section has some good notes There’s a list of all the methods it supplies There’s example code You should be able to download/copy, compile, and run that code Another one to try: C#’s built-in LinkedList class

9 Google tricks add the language (“C#”) – filters out compiled software, and tells Google that you’re interested in source code Add site:stackoverflow.com to search only the stackoverflow.com domain (and any subdomains) Example query: site:stackoverflow.com can’t implement “AVL tree”

10 ‘Library’ of websites Geeksforgeeks.com RosettaCode.com
Videos, code (sometimes in multiple languages), good explanations RosettaCode.com Code with great support for multiple languages Tutorialspoint – has a ‘data structures’ tab San Diego State U lectures Stackoverflow.com Not for newbies  Great for help with errors Sometimes has code samples

11 Stuff To Avoid List Wikipedia
Tends to have pseudocode instead of compiling code Lots of technical jargon – written by experts, for experts

12 How to familiarize yourself with a given codebase, after you’ve found it
Go through the example code Ask yourself why each line/chunk does what it does Ask yourself “How could I use this in my program?” Come up with a very, very simplified version of something that you’ll eventually use in your program. Your IDE may have integrated documentation


Download ppt "Finding and using code online"

Similar presentations


Ads by Google