Skip to content

Instantly share code, notes, and snippets.

View pinkshrub's full-sized avatar

Alan Weber pinkshrub

View GitHub Profile

Alan Weber

[email protected]

Experience

PeopleGIS Tacoma, WA - Software Developer

2019 - 2020

What is get and set?

So first, lets talk about Encapsulation. Encapsulation is the idea that we can hide information and implementation details inside of a class. If we have, for example, a Math class, we would like it to be able to return the absolut value of a number. We dont care necessarily how it does it, only that it does it. It could multiply the value by -1 if it is a negative number or it could take the root of the number's square. What is convenient is that we know where to look if this method doesn't behave properly - inside the Math class! So we can hide complex behavior (if(x>-1){return x}else{return x\*-1}) behind a simple public interface like Math.abs(x) and we can easily change it because it exists in 1 place. Another side effect of encapsulation is that it makes it easy to "hide" where/when change occurs. For example, maybe we don't like that our abs(x) does logic. Maybe its faster if we just do a simple math operation like return sqrt(x*x). We

@pinkshrub
pinkshrub / gist:6c7153e45a844a7a7bedc5111c56f672
Last active February 15, 2022 12:21
Flash Messages in Django

#Flash messages

DOCUMENTATION

###RECAP: One time messages. "Allows you to store messages in one request & retrieve them for display in a subsequent(usually next) request"

###Overview In django, flashed messages are part of the messages app that is included in the generic django-admin startproject command. When used, a message object is added to the request object(via session/cookie) that is readily available for use in views or templates in subsequent requests. Each flash message is an instance of the Message class which has the following attributes: