Failing Another Software Engineer Interview - The Fundamentals I Forgot

Imperative vs Declarative, OOP, Compiled vs Interpreted, and Recursion

By Mark Truong

Hey everyone,

I failed another software engineer interview, and I’d like to reflect on what I did wrong.

This interview was 2 hours long, and I felt I did poorly on keeping calm and collected since I could’ve answered some of the questions.

For one, when they ask why you want to work here, make sure you did some research about the company, list out 2-3 things you like about the company and talk about it.

Another is the Sr Software Engineer looked at my resume and talk about the Programming Languages on my resume and the fundamental differences between them

References:

Imperative vs Declarative

Diagram of programming paradigms splitting into Imperative (procedural, object-oriented, parallel processing) and Declarative (logic, functional, database processing)

Approach for getting a table:

Imperative = how

I see that table over there by Gone fishing sign is empty my husband are going to walk toward the bar, take a right at the bathroom, walk past two tables, then sit down

Declarative = what

Table for two please

Writing operational software is about managing complexity

Dynamically vs Statically Typed Languages

Quadrant chart of typing systems: static vs dynamic on one axis and strong vs weak on the other, plotting Python and Ruby as dynamic, C# and Java as static/strong, JavaScript and PHP as dynamic/weak, and C and C++ as static

Python - Dynamically

Can change a variable from 5 to “five”

Syntactically simpler

Go / TS - Statically

Does not allow to change type of a variable

Larger systems

Type inference x:=5

Makes static type better overall.

Object Oriented Design

Diagram contrasting Procedural programming, shown as a linear chain of Process 1, Process 2, Process 3, with Object-Oriented programming, shown as a Fruits object branching into banana, apple, and mango objects

Another fatal mistake was knowing the fundamentals of object oriented design, the 4 pillars, which are:

Procedural Programming

Functions and data

Object oriented design

Takes these functions and place them into objects, the data as properties and the functions as methods

Encapsulation

Group related variables and functions together into objects. Reduce complexity, increase reusability.

Abstraction

dvd player as object - buttons and logic board. The complexity is hidden from you, can hide properties and methods on the outside. Make interface of those things simpler.

Reduces complexity and isolates the impact of changes

Inheritance

Eliminate redundant code. Generate methods once in an object and have other objects inherit these properties and methods.

Polymorphism

Many Forms, get rid of if / else statements. The method will behave differently depending on the object referencing.

Compiled vs Interpreted Languages

Get source code to machine code before it can run. Compiling source code and interpreting the source code.

Compiled

Source code, program that is a compiler separate file that contains the machine code, and you give the person the file which is an executable. We keep our source code

Pros

Ready to run, faster, source code is private

Cons

Not cross-platform, inflexible, extra step

Interpreted

Give source code copy, machine will interpret it whenever you run the program, it does this on the fly, goes through source code line by line and processing it on the spot, doesn’t save it as the machine code file.

Pros

Cross-platform, simpler to test, easier to debug

Cons

Interpreter required, often slower, source code is public

Intermediate approach

Upfront we compile it half of the way, we call it an intermediate language, then you distribute it to each person to run it, take it the last step to take it to machine code, called JIT compilation, called bytecode

What is the MVC - Model View Controller?

Diagram of the MVC pattern: the User sends a Request to the Controller, which sends Request Data to the Model and gets back Response Data, then sends data to the View, which sends the Response back to the User

Working with complex web apps with patterns to make the less complex and easier to work with.

Split a large application into specific sections that have their own purpose.

Controller handles request flow, gets data from model. The model handles data logic, interacts with database. Model sends request back to controller, then controller gets presentation to view. View handles data presentation and is dynamically rendered.

Presentation of data and logic data separate which makes developing complex applications simple.

How would you code a factorial in pseudocode recursively?

What is recursion?

It helps to visualize a complex problem into basic steps, which can be solved more iteratively and recursively.

# iteratively
def factorial(x):
    if x < 0:
        raise ValueError("Input must be a non-negative integer")
    if x == 0 or x == 1:
        return 1
    result = 1
    for i in range(2, x + 1):
        result *= i
    return result

# recursive
def factorial_recursive(x):
    if x < 0:
        raise ValueError("Input must be a non-negative integer")
    if x == 0 or x == 1:
        return 1
    return x * factorial_recursive(x - 1)

What is big O notation?

Chart of Big O complexity classes plotting time against input size n, from O(1) and O(log n) at the bottom up through O(n), O(n log n), O(n^2), O(2^n), and O(n!) at the top

How code slows as data grows.

  1. Describes the performance of an algorithm as the amount of data increases
  2. Machine independent number rod steps to completion
  3. Ignore smaller operations O(n+1) -> O(n)

n = amount of data passing in

o(1) - constant time

o(n) - linear time

o(logn) - logarithmic time

o(n^2) - exponential time

Anyways, this was a tough one, but I have another interview coming up soon, so I’ll have to use the first tip for that. Funny how I was about 1 hr of YouTube videos away from passing. Stay studying peeps!

Share: X (Twitter) Facebook