This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python OOP Examples | |
from abc import ABC, abstractmethod | |
from datetime import datetime | |
# Abstract Base Class | |
# Defines abstract methods that must be implemented | |
class Building(ABC): | |
# Properties are managed attributes | |
@property |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Observer Design Pattern for Car objects when it starts. | |
""" | |
from __future__ import annotations | |
from abc import ABC, abstractmethod | |
from typing import List, Optional | |
class Subject(ABC): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Observer Design Pattern | |
from __future__ import annotations | |
from abc import ABC, abstractmethod | |
from typing import List, Optional | |
from random import randrange | |
class Subject(ABC): | |
""" | |
The Subject interface declares a set of methods for managing and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dependency Inverson Principle | |
# High level modules should not depend on low level modules | |
# Without Dependency Inversion: | |
class LightBulb_wo: | |
def turn_on(self): | |
print("LightBulb: turned on...") | |
def turn_off(self): | |
print("LightBulb: turned off...") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8; | |
import "forge-std/Test.sol"; | |
import "forge-std/console.sol"; | |
import "../src/StakingRewards.sol"; | |
IERC20 constant WETH = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-2.0 | |
pragma solidity >=0.8.9; | |
contract PayableForward { | |
Forwardee forwardee; | |
constructor(Forwardee forwardee_) { | |
forwardee = forwardee_; | |
} |