Discount systems, booking platforms, contests - all those applications have one thing in common: date & time management. How to implement business logic dependent on the time of the day, week, year? Half-price pizza on Mondays, course registration until the end of August or a landing page available only in November?
I deal with business requirements like these every day at work. I will show you the way I refactored messy code and wrote tests, so other programmers would not be afraid to make changes anymore. I'll convince you to use DateTimeImmutable and show some interesting date/time operations available in PHP standard library.
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Numerical solution of ordinary differential equations by using Runge-Kutta Method of Order Two and Runge-Kutta Method of Order Four
How to write the C++ codes?
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Numerical solution of ordinary differential equations by using Runge-Kutta Method of Order Two and Runge-Kutta Method of Order Four
How to write the C++ codes?
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Learn how to write scripted load tests in PHP to run against your system without breaking the bank. Jason will cover not only the importance of load testing, but share stories of how load tests uncovered problems that would otherwise not have been discovered until production. Also, learn how to use load testing to learn how to deal with large traffic sites without needing to be employed by a large scale site first. We’ll be using RedLine13, an almost free load testing tool that is at the same time inexpensive, easy, and effective.
Instruction1. Please read the two articles. (Kincheloe part 1 &.docxcarliotwaycave
Instruction:
1. Please read the two articles. (Kincheloe part 1 & 2)
2. Please choose some of the topics covered in each chapter, provide a brief summary (2-3 sentences) of those topics.
3. Then add your reflections, insights, or relevant experiences, etc. to help illustrate or expand upon the course.
4. This journal should be at least 400 words.
p5-start.cppp5-start.cpp/**
* @author Jane Student
* @cwid 123 45 678
* @class CSci 430, Spring 2018
* @ide Visual Studio Express 2010
* @date November 15, 2018
* @assg prog-04
*
* @description This program implements a simulation of process
* scheduling policies. In this program, we implement round-robin
* scheduling, where the time slice quantum can be specified as
* as a command line parameter. And we also implement shortest
* remaining time (SRT) scheduling policy
*/
#include<stdlib.h>
#include<iostream>
#include<iomanip>
#include<fstream>
#include<string>
#include<list>
usingnamespace std;
// global constants
// I won't test your round robin implementation with more than 20 processes
constint MAX_PROCESSES =20;
constint NO_PROCESS =0;
// Simple structure, holds all of the information about processes, their names
// arrival and service times, that we are to simulate.
typedefstruct
{
string processName;
int arrivalTime;
int serviceTime;
// holds running count of time slices for current time quantum, when
// serviceTime == quantum, time slice is up
int sliceTime;
// holds total number of time steps currently run, when == to
// serviceTime process is done
int totalTime;
// holds time when process finishes, used to calculate final stats,
// like T_r, T_r/T_s
int finishTime;
// a boolean flag, we will set this to true when the process is complete
bool finished;
}Process;
// Process table, holds table of information about processes we are simulating
typedefstruct
{
int numProcesses;
Process* process[MAX_PROCESSES];
}ProcessTable;
/** Create process table
* Allocate memory for a new process table. Load the process
* information from the simulation file into a table with the process
* information needed to perform the simulation. At the same time we
* initialize other information in process table for use in the
* simulation. Return the newly created ProcessTable
*
* @param processFilanem The name (char*) of the file to open and read
* the process information from.
* @param processTable This is actually a return parameter. This
* should be a pointer to an already allocated array of
* Process structure items. We will fill in this structure
* and return the process information.
*
* @returns ProcessTable* The newly allocated and initialized ProcessTable
* structure.
*/
ProcessTable* createProcessTable(char* processFilename)
{
ifstream simprocessfile(processFilename);
ProcessTable* processTable;
int pid;
string processName;
int arrivalTime;
int serviceTime;
// If we can't open file, abort and let ...
Presented at Agile In Rio, October 2013.
This presentation discusses the risks of leaving small broken windows behind when dealing with a software project and it focuses on easy ways of keeping the code maintainable through time.
Slides are (almost) in English. Codes are in Portuguese, though. I might translate them, eventually.
Advanced patterns in asynchronous programmingMichael Arenzon
Using Futures as a basic building block for concurrent, async code has become pervasive in the past few years and for a good reason. However, when moving from the traditional synchronous code to the async one, a set of patterns that were obvious to implement before now seem to be more challenging. The aim of this talk is to show few examples of these patterns implemented with Scala futures in an async and non blocking manner. We will present the usage pattern and the implementation in order to show the principles of properly handling async code.
When it comes to writing tests we often live in the here-and-now and consequently end up producing "write-only" tests. This session looks at what we need to consider if we want to create tests that our future selves and teammates will find valuable instead of becoming another burden on top of delivering the feature itself.
If there is one place that we find it easy to take shortcuts it's when writing tests. Whether we're under the cosh or have an overly-optimistic view of our ability to write self-documenting code, instead of creating tests that support the production code and development process we can find ourselves producing WTFs (Weak Test Functions). The net effect is often a viscous cycle that disparages, instead of encourages us.
In the past I've tried many different ways to try and short-circuit the test writing process, but have only come-up short every time. This session takes a look at why skimping on elements of the test structure, such as organisation, naming and scope only leads to pain and hardship in the long run. Along the way we'll uncover the truth behind common folklore, such as only having one assertion per test.
Refactoring can either completely disrupt your project or make you go faster. This presentation will help you to avoid some pitfalls.
It also demonstrates refactorings that you could apply straight away to make your code better.
Type hints were introduced with PHP 5. PHP 7 will add the ability to type hint on scalars and even to explicitly state what type will be returned from the function. This talk briefly goes over these added features to PHP 7.
Serial(ize) killers, czyli jak popsuliśmy APIPiotr Horzycki
Wymiana danych to chleb powszedni programisty. Masowo produkujemy REST-owe API, w tym celu używając coraz bardziej zautomatyzowanych narzędzi. Na przykładzie bramki płatniczej opowiem, jak łatwo zdenerwowaliśmy klientów psując używane przez nich API. Pokażę, jak prawidłowo rozwijać publiczne API zachowując jego świeżość, niezawodność i bezpieczeństwo.
Przez kilkanaście lat pracy zawodowej wielokrotnie padłem ofiarą mitów i przejściowych trendów przemysłu IT. Bałem się wysłać CV na widok ściany wymagań. Wprowadzałem Scruma "na siłę", przepisywałem systemy od zera, budowałem wymyślną architekturę. Umknęło mi wiele ważnych rzeczy, na które dziś pragnę zwrócić Waszą uwagę. Opowiem jak możecie ruszyć swoją karierę "z kopyta" poprzez skupienie się na 20% rzeczy, które dadzą 80% rezultatów. Pokażę, jakie praktyki realnie pozwoliły mi osiągać duże sukcesy u klientów z całego świata.
Architecture tests: Setting a common standardPiotr Horzycki
I'm discussing our approach to designing software architecture in a fast-growing startup. You'll know how to set standards in your teams and enforce them with automation.
Software development myths that block your careerPiotr Horzycki
During 15 years of my software development career, I was a victim of numerous myths and fads of the IT industry. "We must have Scrum", "Rewrite everything", Hype-Driven Development, 100% test coverage - just to name a few. You'll learn where do these myths come from, why they're wrong and what are the real-world, battle-tested alternatives. You can skyrocket your career just by focusing on the right things!
Web applications are made of more and more external packages and libraries. It's easy to pull "free stuff" from the Web, but is it as easy to maintain a big project composed from random dependencies? Based on my experience with enterprise-grade payment systems I will tell you how we ensure the security of our applications, how we pick the best libraries and how we avoid being sued for copyright infringement. You will learn software development driven by a reliable analysis and not just hype, Stack Overflow and GitHub stars.
How to count money with Java and not lose itPiotr Horzycki
Do you know Bill Karwin's joke about handling money with FLOAT? No? Then you should come to my talk. Most of the systems we develop deal with monetary amounts, and yet we know so little about money handling intricacies. This can lead to serious bugs costing millions of dollars. I will share my experience with the Java Money standard and talk about developing complex e-commerce and payment systems.
Jak zacząć, aby nie żałować - czyli 50 twarzy PHPPiotr Horzycki
Prezentacja na phpCE Polska 2017. Omawiam historię PHP oraz sposób, w jaki wykorzystujemy go dzisiaj. Pokazuję, w jaki sposób wybierać narzędzia i architekturę, aby nasze projekty żyły na produkcji długo i szczęśliwie.
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...ssuser7dcef0
Power plants release a large amount of water vapor into the
atmosphere through the stack. The flue gas can be a potential
source for obtaining much needed cooling water for a power
plant. If a power plant could recover and reuse a portion of this
moisture, it could reduce its total cooling water intake
requirement. One of the most practical way to recover water
from flue gas is to use a condensing heat exchanger. The power
plant could also recover latent heat due to condensation as well
as sensible heat due to lowering the flue gas exit temperature.
Additionally, harmful acids released from the stack can be
reduced in a condensing heat exchanger by acid condensation. reduced in a condensing heat exchanger by acid condensation.
Condensation of vapors in flue gas is a complicated
phenomenon since heat and mass transfer of water vapor and
various acids simultaneously occur in the presence of noncondensable
gases such as nitrogen and oxygen. Design of a
condenser depends on the knowledge and understanding of the
heat and mass transfer processes. A computer program for
numerical simulations of water (H2O) and sulfuric acid (H2SO4)
condensation in a flue gas condensing heat exchanger was
developed using MATLAB. Governing equations based on
mass and energy balances for the system were derived to
predict variables such as flue gas exit temperature, cooling
water outlet temperature, mole fraction and condensation rates
of water and sulfuric acid vapors. The equations were solved
using an iterative solution technique with calculations of heat
and mass transfer coefficients and physical properties.
We have compiled the most important slides from each speaker's presentation. This year’s compilation, available for free, captures the key insights and contributions shared during the DfMAy 2024 conference.
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...Amil Baba Dawood bangali
Contact with Dawood Bhai Just call on +92322-6382012 and we'll help you. We'll solve all your problems within 12 to 24 hours and with 101% guarantee and with astrology systematic. If you want to take any personal or professional advice then also you can call us on +92322-6382012 , ONLINE LOVE PROBLEM & Other all types of Daily Life Problem's.Then CALL or WHATSAPP us on +92322-6382012 and Get all these problems solutions here by Amil Baba DAWOOD BANGALI
#vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore#blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #blackmagicforlove #blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #Amilbabainuk #amilbabainspain #amilbabaindubai #Amilbabainnorway #amilbabainkrachi #amilbabainlahore #amilbabaingujranwalan #amilbabainislamabad
6th International Conference on Machine Learning & Applications (CMLA 2024)ClaraZara1
6th International Conference on Machine Learning & Applications (CMLA 2024) will provide an excellent international forum for sharing knowledge and results in theory, methodology and applications of on Machine Learning & Applications.
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdffxintegritypublishin
Advancements in technology unveil a myriad of electrical and electronic breakthroughs geared towards efficiently harnessing limited resources to meet human energy demands. The optimization of hybrid solar PV panels and pumped hydro energy supply systems plays a pivotal role in utilizing natural resources effectively. This initiative not only benefits humanity but also fosters environmental sustainability. The study investigated the design optimization of these hybrid systems, focusing on understanding solar radiation patterns, identifying geographical influences on solar radiation, formulating a mathematical model for system optimization, and determining the optimal configuration of PV panels and pumped hydro storage. Through a comparative analysis approach and eight weeks of data collection, the study addressed key research questions related to solar radiation patterns and optimal system design. The findings highlighted regions with heightened solar radiation levels, showcasing substantial potential for power generation and emphasizing the system's efficiency. Optimizing system design significantly boosted power generation, promoted renewable energy utilization, and enhanced energy storage capacity. The study underscored the benefits of optimizing hybrid solar PV panels and pumped hydro energy supply systems for sustainable energy usage. Optimizing the design of solar PV panels and pumped hydro energy supply systems as examined across diverse climatic conditions in a developing country, not only enhances power generation but also improves the integration of renewable energy sources and boosts energy storage capacities, particularly beneficial for less economically prosperous regions. Additionally, the study provides valuable insights for advancing energy research in economically viable areas. Recommendations included conducting site-specific assessments, utilizing advanced modeling tools, implementing regular maintenance protocols, and enhancing communication among system components.
Student information management system project report ii.pdfKamal Acharya
Our project explains about the student management. This project mainly explains the various actions related to student details. This project shows some ease in adding, editing and deleting the student details. It also provides a less time consuming process for viewing, adding, editing and deleting the marks of the students.
Hierarchical Digital Twin of a Naval Power SystemKerry Sado
A hierarchical digital twin of a Naval DC power system has been developed and experimentally verified. Similar to other state-of-the-art digital twins, this technology creates a digital replica of the physical system executed in real-time or faster, which can modify hardware controls. However, its advantage stems from distributing computational efforts by utilizing a hierarchical structure composed of lower-level digital twin blocks and a higher-level system digital twin. Each digital twin block is associated with a physical subsystem of the hardware and communicates with a singular system digital twin, which creates a system-level response. By extracting information from each level of the hierarchy, power system controls of the hardware were reconfigured autonomously. This hierarchical digital twin development offers several advantages over other digital twins, particularly in the field of naval power systems. The hierarchical structure allows for greater computational efficiency and scalability while the ability to autonomously reconfigure hardware controls offers increased flexibility and responsiveness. The hierarchical decomposition and models utilized were well aligned with the physical twin, as indicated by the maximum deviations between the developed digital twin hierarchy and the hardware.
2. What's time got to do with
web applications?
●
News, movies & other content
●
Voting systems
●
Subscriptions with time constraints
(like "Call For Papers":
https://github.com/opencfp/opencfp)
●
Discount systems
●
Reports, statistics
3. A very bad example...
class SuperMegaFancyPromotionController
{
public function showAction()
{
if (time() > 1496268000) {
$this->showForm();
} elseif (time() < 1490997600 && time() > 1488322800) {
$this->showWarning();
} else {
/* ... */
}
}
}
This code:
- is hard to read
- cannot be easily tested (see uopz extension)
- is not reusable
- must be modified even if somebody wants to change the dates (hardcoding)
4. Date & time operations in PHP
●
date(), time(), strtotime(), strftime()...
●
DateTime
●
DateInterval
●
DatePeriod
●
DateTimeZone
5. UNIX timestamps
●
A signed integer; a number of seconds since the "epoch"
– 1970-01-01 Coordinated Universal Time (UTC)
●
On 32-bit systems, the maximum supported year was 2038
●
On 64-bit systems, PHP 7 works beyond the year 2038:
$ php -r "echo strtotime('1939-09-01');"
-957315600
$ php -r "echo strtotime('2049-09-01');"
2514063600
6. Why use functions if we have
classes?
function getNextMonthAsRSSDate(DateTimeImmutable $date): string
{
$nextMonth = $date->add(new DateInterval('P1M'));
return $nextMonth->format(DateTime::RSS);
}
function getNextMonthAsRSSDate(int $date): string
{
$nextMonth = mktime(
date('H', $date), date('i', $date),
date('s', $date), date('n', $date) + 1
);
return date('D, d M Y H:i:s O', $nextMonth);
}
7. DateTimeImmutable vs DateTime
PHP Manual on DateTimeImmutable:
„This class behaves the same as DateTime except it never modifies itself but
returns a new object instead.”
Thus, DateTimeImmutable is a value object, known from DDD.
$now = new DateTime();
$nextMonth = $now->add(new DateInterval('P1M'));
/* $now and $nextMonth are pointers to the same object;
* we need two separate value objects! */
debug_zval_dump($now);
debug_zval_dump($nextMonth);
8. Timezones are tricky
●
Your server has its local time, your users have their
own local time
●
Daylight Saving Time works differently in different
countries
●
Timezones are not always shifted by whole hours
(like +8:45 in Australia)
●
Solution: store all dates in Coordinated Universal
Time – and convert back to local time in the
presentation layer
12. Creating intervals in ISO 8601 syntax
$interval = new DateInterval('P1Y2M3DT4H5M6S');
$interval = new DateInterval('P0001-02-03T04:05:06');
=
1 year, 2 months, 3 days,
4 hours, 5 minutes and 6 seconds
13. Periods
function printSchoolYearMondays()
{
$start = new DateTimeImmutable('2017-09-01Z');
$end = new DateTimeImmutable('2018-06-30T23:59:59Z');
$interval = DateInterval::createFromDateString('next monday');
$period = new DatePeriod(
$start,
$interval,
$end,
DatePeriod::EXCLUDE_START_DATE
);
foreach ($period as $date) {
// $date is immutable if $start is too
echo $date->format('l, Y-m-d') . PHP_EOL;
}
}
14. Date ranges in MySQL
SELECT *
FROM news
WHERE
YEAR(published_at) = 2017 AND MONTH(published_at) = 11;
SELECT *
FROM news
WHERE
published_at BETWEEN '2017-11-01' AND '2017-11-30 23:59:59';
SELECT *
FROM news
WHERE
published_at LIKE '2017-11-%';
15. class MonthPeriod
{
public function getStart()
{
return new
DateTimeImmutable('first day of this month midnight');
}
public function getEnd()
{
return new
DateTimeImmutable('first day of next month midnight -1 second');
}
}
define('SQL_DATETIME', 'Y-m-d H:i:s');
$period = new MonthPeriod();
echo $period->getStart()->format(SQL_DATETIME) . PHP_EOL;
echo $period->getEnd()->format(SQL_DATETIME) . PHP_EOL;
// Output:
// 2017-11-01 00:00:00
// 2017-11-30 23:59:59
These two values are ready to be bound into a BETWEEN … AND … statement.
16. Remember about tests!
class MonthPeriod
{
private $now;
public function __construct(DateTimeImmutable $now)
{
$this->now = $now;
}
public function getStart()
{
return $this->now->modify('first day of this month midnight');
}
public function getEnd()
{
return $this->now->modify('first day of next month midnight -1 second');
}
}
17. class MonthPeriodTest extends PHPUnitFrameworkTestCase
{
/** @dataProvider getDateRanges */
public function testMonth(
string $today,
string $expectedStartDay,
string $expectedEndDay
) {
$now = new DateTimeImmutable($today);
$period = new MonthPeriod($now);
$expectedStart = new DateTimeImmutable($expectedStartDay);
$expectedEnd = new DateTimeImmutable($expectedEndDay);
$this->assertEquals($expectedStart, $period->getStart());
$this->assertEquals($expectedEnd, $period->getEnd());
}
public function getDateRanges()
{
return [
'November' => [
'2017-11-11Z', '2017-11-01 00:00:00Z', '2017-11-30 23:59:59Z'
],
'Leap year' => [
'2016-02-11Z', '2016-02-01 00:00:00Z', '2016-02-29 23:59:59Z'
],
];
}
}
18. Date and time arithmetic pitfalls
$lastDayOfJanuary = new DateTimeImmutable('2016-01-31Z');
echo $lastDayOfJanuary
->modify('+1 month')
->format('Y-m-d') . PHP_EOL;
echo $lastDayOfJanuary
->modify('last day of next month')
->format('Y-m-d') . PHP_EOL;
// Output:
// 2016-03-02
// 2016-02-29
More: http://php.net/manual/en/datetime.examples-arithmetic.php
More: Michał Pipa, Data i czas dla programistów (https://youtu.be/ZRoEVJlxPlo)
19. A bad example, once again...
class SuperMegaFancyPromotionController()
{
public function showAction()
{
if (time() > 1496268000) {
$this->showForm();
} elseif (time() < 1490997600 && time() > 1488322800) {
$this->showWarning();
} else {
/* ... */
}
}
}
20. Let's rewrite that legacy code...
class PromotionTimelineTest extends PHPUnitFrameworkTestCase
{
public function testIsActive()
{
$now = new DateTimeImmutable('2017-05-01T00:00:00Z');
$opening = $now;
$closing = $opening->add(new DateInterval('P2M'));
$timeline = new PromotionTimeline($now, $opening, $closing);
$this->assertTrue($timeline->isActive());
}
}
...starting from a test
21. Testing the exceptions
class PromotionTimelineTest extends PHPUnitFrameworkTestCase
{
/* ... */
/**
* @expectedException InvalidArgumentException
*/
public function testInvalidArguments()
{
$now = new DateTimeImmutable('2017-05-01T00:00:00Z');
$opening = $now;
$closing = $opening->sub(new DateInterval('PT1S'));
new PromotionTimeline($now, $opening, $closing);
}
}
22. class PromotionTimeline
{
private $now;
private $openingDate;
private $closingDate;
public function __construct(
DateTimeImmutable $now,
DateTimeImmutable $openingDate,
DateTimeImmutable $closingDate
) {
if ($openingDate >= $closingDate) {
throw new InvalidArgumentException('The opening date must be
earlier than the closing date');
}
$this->now = $now;
$this->openingDate = $openingDate;
$this->closingDate = $closingDate;
}
public function isActive()
{
return
($this->now >= $this->openingDate) &&
($this->now < $this->closingDate);
}
}
23. What might come next?
●
Early-bird tickets
●
Reminders
●
Last-minute tickets
●
Individual coupons valid until ...
●
Black Friday
●
...
Expect the unexpected!
24. Remember the Strategy pattern!
●
Let's say we develop a hotel booking platform
●
Ordinary users have to check out at a fixed
hour specified by the hotel
●
But the premium users have extra time!
26. interface CheckoutStrategyInterface
{
public function getCheckoutTime();
}
class User
{
private $checkoutStrategy;
public function __construct(CheckoutStrategyInterface $checkoutStrategy)
{
$this->checkoutStrategy = $checkoutStrategy;
}
public function getCheckoutTime()
{
return $this->checkoutStrategy->getCheckoutTime();
}
}
Doing it the flexible way
27. class StandardCheckoutStrategy implements CheckoutStrategyInterface
{
private $checkout;
public function __construct(DateTimeImmutable $checkout)
{
$this->checkout = $checkout;
}
public function getCheckoutTime()
{
return $this->checkout;
}
}
28. class ExtendedCheckoutStrategy extends StandardCheckoutStrategy
{
private $extension;
public function __construct(
DateTimeImmutable $checkout,
DateInterval $extension
) {
parent::__construct($checkout);
$this->extension = $extension;
}
public function getCheckoutTime()
{
return $this->checkout->add($this->extension);
}
}
29. Why do we create so many
classes?
●
A class should be modified only for a single
reason
●
Single-responsibility principle
●
Flexibility: loose coupling, high cohesion
●
You never know what business
brings next
●
But don't over-engineer!
30. Distributed systems
●
Servers in multiple timezones? Oops...
●
Date synchronization via Network Time Protocol
●
Time events
●
A lot of fun :)