Skip to content

Instantly share code, notes, and snippets.

class ScoreCounter:
def __init__(self):
self.pins_down = None
def roll(self, pins_down):
self.pins_down = pins_down
def score(self):
return self.pins_down
@HelloThisIsFlo
HelloThisIsFlo / the-web-pt-1-1.rb
Last active January 26, 2017 08:21
Application
def multiply(a, b), do: a * b
def main(args) do
{a, b} = read_from_command_line(args)
result = multiply(a, b)
print_human_readable_result({a, b}, result)
end
@HelloThisIsFlo
HelloThisIsFlo / the-web-pt-1-2.py
Created January 26, 2017 08:23
Human Readable Result
####################
### RESULT ###
####################
// Hello, I am a human readable result! //
Computation: "2 * 2"
|> Result: 4
The classic scenario - Server-side rendering
Don't fear the complex name, Server-side rendering is actually a pretty simple process.
To understand, let's first imagine a simple non-web application: A command line application.
<!DOCTYPE html>
<html>
<body>
<h1>This is the result</h1>
<p>$$$$$$$</p>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1>This is the result</h1>
<p>4<p>
</body>
</html>
<div id="menu" style="visibility: hidden">
|
Javascript: when clicking menu, do: |
V
<div id="menu" style="visibility: visible">
{"book": {
"title": "Moby Dick",
"author": "Herman Melville",
"reviews": [
{"reviewer": "Mark234", "rating_stars": "4.5"},
{"reviewer": "Frank12", "rating_stars": "3.5"},
{"reviewer": "NotPatrick", "rating_stars": "4"},
]
}
}
@RequestMapping("/itinerarySelection")
public String showItinerarySelection(Request request, Model model) {
// Retrieve ID (Here stored with the client)
String trackingId = request.getParameter("trackingId");
//////////////////////////////////
// Query the Application layer //
//////////////////////////////////
List<RouteCandidate> routeCandidates =
bookingService.requestPossibleRoutesForCargo(trackingId);
public interface BookingService {
TrackingId bookNewCargo(Location origin, Location destination);
CargoRouting findCargoRoutingInformations(TrackingId Id);
List<RouteCandidateDTO> requestPossibleRoutesForCargo(TrackingId id);
void assignCargoToRoute(TrackingId id, RouteCandidate route);
void changeDestination(TrackingId id, String destinationUnLocode);