Master

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What is the What If I Were Perfect Technique?

- Assume that a solution exists (your situation is not unique)<br>- Imagine you are the smartest, most resourceful person on the planet<br>- Since you are the most resourceful person, tell yourself how to solve the problem. <br><br>How would Elon Musk handle it?

how to cast str, floats, and ints to different types, what are the methods?

.to_s<br>.to_i<br>.to_f

What are teh two layers to solving any coding problem?

1 The logical domain layer<br>2 The syntactical programming language layer

What are the 5 Big Career Paradigm Shifts

1. Get proactive<br>2. Build a system<br>3. Front-load the work<br>4. Think about what others want<br>5. Use competence triggers to signal your mastery

What are the steps for debugging?

1. Reproduce the error -- A deterministic way to reproduce the problem so we can isolate root cause.<br>2. Determine the boundaries of the error -- play with it, investigae where it touches other code. Modify the data or code to understand the scope of the error.<br>3. Trace the code

What are the three questions to ask yourself when designing a db?

1. What are the models the webiste needs?<br>2. what are the attributes the models need?<br>3. what are the relationships between the models?

What is the shovel operator?

<<<br><br>used to append text to an object

What is SCM or VCS? Why do we need this?

A Source Control Management or Version Control System is a way to take snapshots of files as we change and update them. This give us a log and a history so we can track down bugs, track changes, and keep a record.

What is a code linter?

A code linter is a program that inspects your code for possible logical errors or code smells. This isn't foolproof, but can serve as a first level of defense against obvious problems.

What is a repository?

A collection of files saved together for version control.

What is a constructor? Give an example.

A constructor is a class method that is responsible for building/instantiating an instance of the class. <br><br>The __init__ function in python.

What is a branch? What does forking mean?

A copy of all the files in you repo. Each branch has its own name and commit history. The default branch of a new repo is master.<br><br>Forking is creating another branch from an existing one.

What is a hash? How do you hash. What is the challenge facing hashing?<br><br>What are collisions?

A hash is a table that we index into with a key. The idea behind hashing is that you can convert any object into a number because everything in a computer can be reduced to binary and binar to a number.<br><br>Hashing is a way of encoding objects into an integer. Problem is if we do a straight conversion using octal conversion of say characters in a string we will end up with a massive space that we would need to allocate for our table. We must reduce the table size to something decent and account for collisions.<br><br>Collisions are when two objects reduce to the same integer in a table.

What function does every C++ program have?

A main function

What is a public vs. private member of a class? Why is a public field not OOP?

A public member of a class is something accessible from outside of the class whereas a private member is something only accessed by the class.<br><br>A public field is bad OOP because it breaks encapsulation. Strictly speaking all data in a class should be private and only accessible by methods of the class. Methods can be either private or public.

What is a relational database? What are the advantages of a database?

A relational database is a grouping of related data. <br><br>The advantage of a DB is that it is safe, secure, fast to access, concurrent access (multiple users).

What is a Singleton? Why is it useful?

A singleton is a OOP design pattern where only one instance of a class is allowable (conceivably). They solve the issue where you can have only one instance and you manage on instance. Best for log files.

What is imperative/procedural mean?

A step by step way to solving a problem...<br><br>This is different then using a function that takes care of several steps for you.

What is a symbol and how do you create it?

A symble is a string-like reference that you use when you don't ever intend to print it or change it. An immutable string. The syntax is<br>:textgoeshere

What is the result of any query to your database?

A table!

A/B testing is?

A/B testing is comparing the performance of two different implementations of your product.

What expressions evaluate to true in ruby?

All of them except for false and nil

Constants are denoted by...

All upper case letters LIKE_THIS

Why do you need to use an id?

Because names aren't necessarily unique. Yo uneed to have unique keys for objects or for representing people for examp;le.

Why is fidelity of environment important when deploying and testing code?

Becuase you only want to make one change at a time! So you can be sure of the sources of any bugs that may occur.

What is Blackbox, glassbox, and whitebox testing?

Blackbox is testing inputs and outputs without regards to internal logic. Whitebox testing is tracing every path through your logic. And glassbox testing IS whitebox testing.

Who are the stake holders of the distributed grid?

Business: <br>- Distributed grid resource providers such as SolarCity, wind, solar, and other energy producers.<br>- Utitilities are being threatened right now as energy producers.<br>- Industry and Institutions<br>- The Public:<br>Individuals who use the energy including buisinesses. Almost everyone is a stakeholder.

What does CSV stand for?<br>What does JSON stand for?

CSV = comma separated value<br>JSON = Javascript Object Notation

Top 5 file types to know about in business software and web applications...

CSV, JSON, XML, HTML, XLS

What are class members and why aren't they OOP? What is another name for class field or class method?

Class members are data and methods on the class and not on an instance. This isn't OOP stricly speaking because this is procedural programming and breaks encapsulation. A static field (class field) is basically a global variable. A static method (class method) is a global method meaning it exists outside of an instance of a class.

What is another name for making a code 'checkpoint' using git?

Commit

What is composition in OOP?

Composition is the idea that objects are made up of other objects. This is different from inheritance where the object is a subtype of the object.<br><br>For example a lizard is an animal but a claw isn't a lizard, it's something a lizard has.

How manyh samples do we need to look at in order to have justified confience that something is true about the population?

Depends on teh variance in the population. This means we run multiple trials that are independent of each other then examine the variance between the trials/samples.

What is encapsulation?

Encapsulation is a philosophy of design that is fundamental to OOP that describes a way of modularizing your code by specifying how data can flow between two objects or from an object to any other area. <br><br>An object contains data (fields) and methods (functions). In OOP you want your data to only be accessible by your methods and in this way keeps it very clear how your data is accessed and how it can be changed. This keeps code modular and clean. <br><br>This is essentially layering code in a consistent way that allows code to be predictable and idiomatic.<br>

What does XML stand for?

Extensible Markup Language

What are feature toggles?

Feature toggles are features you are adding to the project for a big feature but you wrap the 'jagged' or uncompleted portions of the code in a 'toggle' that lets you hide the code from deployment.

When should you use snake_case? Constants are denoted with..? When shoudl you use CamelCase?

For naming a file, a method, or a variable<br><br>ALL CONSTANTS<br><br>Use CamelCase when defining a Class

Why do utilities add capacitor banks to transmission lines?

For transmission level lines one of the biggest losses of power is reactive power or basically inertia and electrical 'friction' of the field as the inductance of the line tries to maintain its field with an AC current. We add capacitance to balance the inductance properties of the line and the load on the system (which is primarily inductive). We are trying to balance out the load and can connect and disconnect cap banks to correct power factor with various loads.

How do you handle collisions when hashing?

Hashing is a many to one mapping. You put a collision into the next available spot in the table. Or you have a hash bucket (a llist) in which you append keys to a tuple in the list at the map location.

What is the gambler's fallacy?

If deviations from expected occur, these deviations are likely to be evened out byh opposite deviations in the future... FALSE belief...

What is the law of large numbers? (Bernoulli's law)

In repeated independent tests with the same actual probability of a particular outcome in each test, the chance that the fraction of time that outcome occurs differs from p converges to zero as the number of trials foes to infinity.<br>Basically as we go to infinity we approach the truth. Or better approximate it.

What are canary releases?

Incremental rollouts, like blue-green but one of them is basically a beta so you limit your risk with the number of users you roll it out to.

What is inheritance?

Inheritance is the idea that there will be subtypes of classes and you don't want to repeat common functionality so a subclass inherits from its parent and is said to be a child of that parent. This means it inherits all class members from its parent and so doesn't need to be repeated. <br><br>However, class members can be overwritten in the child denoting new behavior. Inheritance is reallly just a way to denote relationships of inherited common functionality and a good way to nicely model real world hierarchical relationships. It is also DRY programming.

What is the purpose of .gitignore?

It allows you to include files in your repository that you do not want to share. This could include data that is local to your application but you do not want to share with otehrs.

What is an & in a method name? Why do we care about this?

It denotes that the variable being passed to the method is a 'block'<br><br>Basically we create a method that accepts another method or function inside of it.<br><br>Note: a block must be the last parameter in a method definition.

What is the ternary operator? Give an example of its usage.<br>

It is a compact if statement.<br><br>true ? "this is true" : "this is not true"<br>(4==4) ? "duh" : "How in the..."

What is an ORM?

It is a mapper that converts your code to SQL or maps it to your database. It standds ofr Object Relational Mapper. Bust basically we can use it to do SQL and Python all at once.

What is a factory design pattern in OOP?

It is a pattern used to create instances of other objects without exposing the creation logic to the user. It encapsulates creation logic. <br><br>As a static factory it also creates one place for all of your objects to be created.<br><br>Or if you use it as a class it can be polymorphic.

What is a case statement. Give a usage example

It is like a modified if statement but it can be used to dynamically store variables, or add branching during a variable assignment.<br><br>a=1<br><br>answer = case<br> when a == 2<br> "a is 2"<br> when a == 1<br> "a is 1!"<br> else<br> "a is neither 1 or 2"<br> end<br><br>puts answer

How can you know the truth of a hypothetical probability experimentally?

It is never possible to be assured of perfect accuracy through sampling unless you sample the entire population.

What does the .select method od?

It iterates over an array and returns all elements that meet the criteria specified.<br><br>numbers.select{|n| n>10}<br><br>In this case all numbers > 10 will be returned as an array or subcollection of the original array.

What does the uniq method do when called on an array?

It returns an array of a 'set' from that collection. Meaning it returns all the unique values AKA a set.

How does ruby handle indexing beyond an array?

It returns nil (and doesn't throw and error)

what does the 'next' keyword do in a loop?

Jumps to the next loop iteration, useful if you want to skip over some logic in the loop based on some conditions.

How do you define a constant?<br>A global?<br>A class var?<br>An instance var?<br>A local var?

LIKE_THIS = 'stuff'<br>$like_this = 'stuff'<br>@@like_this = 0<br>@like_this = 'stuff'<br>like_this = 'stuff<br>

What is an MVC architecture? What is the flow?

MVC = Model View Controller<br><br>A user uses a Controller to manipulate the model and the model then updates the 'view' which the user sees and then continues to manipulate the model and round we go.

Blue-green deployment?

Maintaining two separate but identical deployment environments. Only one is active. You deploy a change to the active one and test the green one. Once the green one is working well you take the blue offline and make the green one live. So it seems to you have a stable release you have out that you have ready to swap in?

What are iterators? Why might they be nicer than a loop?

Methods on data that do something with each element in a collection. They are nicer than a loop because they are concise.

Is Python pass by value or pass by reference?

Neither! You bastard! It is pass by object.

What is OOP?

Object Oriented Programming is a methodology and philosophy of designing programs in a way that prioritizes data types over the actions (AKA functions) that operate on those data types.

Why do we want a hash function to have a uniform distribution? How do we implement a hash function?

Otherwise there will be too mank collisions and we want our time cost is equal to n/k where n is the number of insertions and k is the number of buckets<br><br>A hash function is simply something that is cyclic mathematically. For example modulus. We want our function to map a large space of ints to a small s[ace of ints.

What are vairables? When you pass a variable to a function what are you doing? What do you eneed to be careful of?

Pointers to physical space in memory.<br><br>When you pass a variable to a function you are assigning a variable to a variable. You need to be aware that if you mutate the passed in variable it will change your original variable.

Explain polymorphism in simple terms. Give an example.

Polymorphism is the idea that you define a class or type. Let's say we define a type of game. It's a card game. You play with 52 cards. But then there are many type of card games and although the are all CardGames they play differently so if we had an action (method/function) called DealCards then we might deal a different amount of cards depending on the game or instance of CardGame that we are playing.<br><br>More specifically and more accurately we might say we have a Bobcat class and we have a litter of cats named Sally, Joe, and Resus. Now they all have the Hiss action (method) but maybe they all hiss a little differently. So even though they all Hiss each Hiss is a little different for each cat (instance) of Bobcat.

What is a proc?

Procs are blocks that are wrapped in a proc objects and stored in a vairable to be passed around. A proc is like an abbreviated function definition.

What does git clone do?

Pull down contents of existing remote repo into a new local repo, and add a remote to the local repo pointing to remote repo.

How many spaces is the style for indentation? What kind of case does ruby use? What is snake vs. camel case

Ruby uses 2 spaces for indents as the de facto standard. Ruby uses snake cases which is:<br><br>this_is_snake<br>thisIsCamel

What are the different fault types?

Single phase to ground, phase to phase, double phase to ground, and three phase to ground

Wjat does .delete do? What doees .delete_at do??

The delete method removes all instances of its argument from the collection.<br><br>arr = [a,b,c,a]<br>arr.delete('a')<br>arr = [b,c]<br><br>It deletes a value in a collection at a certain index.

What does the 'gets' method do?<br>What is the output of:<br>a = 4<br>b = a<br>a = 7<br>puts b<br>Why?

The gets method is like the input method in python it is a loop waiting for user input.<br><br>b = 4<br><br>Integers and strings in python and ruby are not deeply linked. But arrays and dictionaries would be.

Array Class:<br>What is the:<br> inlude? method<br>flatten method<br>each_index method

The include? method is a boolean return method that checks if its argument is in the array and returns T/F if it is or isn't<br><br>The flatten method takes a nested structure of arrays and makes it into a 1d array.<br><br>The each_index method iterates through the array like each but the var represents the index as opposed to the value. It passes the index into the block. The original array is returned..

What are ruby gems?

There are two main sides to this term. The first side refers to a collection of Ruby files, or Ruby library, that performs a certain task. The other side refers to the publishing system that is behind organizing, listing, and publishing those libraries, or gems.<br><br>The publishing system behind RubyGems is designed to let you download, publish and use useful ruby libraries on your system. That system is powered by the website rubygems.org. The libraries that the system publishes are called "gems".

What is the difference between .map and .collect?

There is no difference the method 'collect' is an alias for map

What are: @classmethod, @staticmethod, @property?

These are functional programming, public method, public field.<br><br>The things with the @ symbol are called decorator. This is a function that either takes a function or returns a function or takes a class and returnsa class.

What is regression testing? What is unit testing?

This is testing software that was previously tested and hasn't changed BUT who has third party software or software that interacts with the software in question, that has changed. Did the change in someone others code break your code? Were there unforeseen interdependencies?<br><br>Unit testing is a software testing methodology in which the smallest testable parts of an application (AKA units) are tested and independently validated. Often automated and can make up a regression test.<br>

What does this function return? does it mutate the caller?<br><br>a.map {|num| num**2}<br><br>

This squares every element in the collection called a. It doesn not mutate the caller but instead returns a new array.

Why should you treat your infrastructure as code?

To maintain fidelity of environment. So you can track changes and ensure same system conditions accross your machines.

When is regex useful?

When you want to do string pattern matching.

What is the I,I,I syndrome?

You are more likely to get what you want if you focus on what others want. Ask the right questions. Don't talk about yourself unless the time is right.<br><br>Scratch their back they scratch yours. Help enough otehr people get what they want and you can get what you want.

What is the Nod&Shrug Reflex?

You tell someone what they need to do and it just bounces off them. Its when they are like 'yeah, yeah' I know but they don't take any action.

When do you use do..end and when do you use {}

You use {} when your code will fit in a single line and do...end when you need a multiline block of code.

What should you do when learning a new concept?

You want to connect this new concept to your previous experiences. Sometimes new concepts--especially abstract ones are hard to connect to your past experiences. Here are some simple ways to make it stick:<br><br>1. Mimic and copy<br>2. Make it your own and play<br>3. Teach it

How do you do string interpolation?

a = 'var'<br>'this is a string with interpolation #{a}'

What is the trade off of a hash table

a time/tradeoff. <br><br>Larger the space, the faster the look up... but the faster the lookup the more space needs to be allocated..<br>

What is the gem 'pry' and how do you use it?

add a:<br>require "pry" to the start of your .rb file, then put binding.pry at some point where you want to debug your program. You can continue program execution with Ctrl+D

form for the .each_with_index method

array.each_with_index do |item, index|<br>

What is the form of an exception rescue in Ruby?

begin<br> #perform code<br>rescue<br> # do if code fails, like log the error<br>end

What is the difference between each and map?

each returns the original array where map returns an updated array depending on your actions during iteration.<br><br>Use each for iteration and map for transformation.

what is the command used to 'stage' a commit?

git add file1 file2 filen

What does the git log do? What argument goes in git commit -m?

git log prints a log of commits for the repo<br>git commit -m 'some description of commit goes here'

break down this command:<br>git remote add bluesky url_to_remote_repo

git remote -> primary git command<br>add -> sub command<br>bluesky -> an alias for the repo you are linking to<br>url -> repo you are linking to

How can we check a hash that a specific key exists? How can we get all key, value pairs that meet a conditional? What does fetch do? When would yo uuse it? How can you transform your hash to an array?

hash.has_key?<br>hash.select { |key, value| key == "lala"} # selects all keys that == lala<br> <br>hash.fetch("Larry") searches for a key called "larry" and if it finds it, it returns the value... the advantage is, you can return a message if the value isn't there. hash.fetch("larry", "larry not found")<br><br>hash.to_a returns an array version of the hash.

How do you return the keys and value of you hash?

hash.keys<br>hash.values

Explain what is-a vs. has-a gets at? What is the principle?

is-a is denoting a subtype/inheritance type relationship whereas has-a is denoting a composition type relationship.

How do you create a dicitonary?

like_this = {like: 'this'}<br>like_this[:like]

What are the diffrent loop structures in ruby?

loop<br>while<br>do while -> this is used when we want the loop to happen at least once<br>for each<br>until

What are the arguments to File.open? What do they mean? How do you open a file in read only mode?

r => read only<br>w => write-only (overwrites all)<br>w+ => read and write (overwrites)<br>a+ => read and write, if file exists append to end else create new<br><br>File.open("filename", "r")

What is RANT? What does it imply?

randome acts of non productive tactics...<br><br>DON'T do these things. Don't be BUSY, be productive.

Ruby uses snake case for what and camel case for what?

snake case for methods and variables, and camelcasse for classes

How can you do a simple check if a character--lets say s--is in a string in Ruby using regex?

string =~ /s/<br>returns the index location in the string where there was a match

What does the bang operator at the end of a method mean?

the ! at the end of a method indicates that the method will mutate the information passed into it permanantly.


Kaugnay na mga set ng pag-aaral

Canadian Health Care Delivery System

View Set

Chapter 9 Thermo, Nader, Helseth

View Set

Respiratory System - Post Lab Quiz

View Set

Texas life insurance exam part 3

View Set

Reading Comprehension: Pobre Pablo [DEPORTES]

View Set