Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Laracon Online 2020 - Refactoring to Simplicity
Search
Marcel Pociot
August 26, 2020
Programming
980
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Laracon Online 2020 - Refactoring to Simplicity
Marcel Pociot
August 26, 2020
More Decks by Marcel Pociot
See All by Marcel Pociot
BotMan - From Zero to Chatbot [Laravel Live]
mpociot
1
310
Other Decks in Programming
See All in Programming
R8 の設定見直しでアプリサイズ削減
andpad
0
220
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
260
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.9k
The Rails Doctrine Decade
koic
2
590
気持ちぃ〜角丸 Squircle
ryu1013
0
310
Simple Storage Service(S3) is not simple
iwatsukayura
0
290
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.6k
Railsのためのパスキー実践入門 〜マルチテナントSaaSでの意思決定〜
utakaha
2
560
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
180
JIS keyboard support in Omarchy
lef237
0
110
Agents on Rails - Rails at Scale 2026
irinanazarova
0
560
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
210
Featured
See All Featured
Chasing Engaging Ingredients in Design
codingconduct
0
360
Odyssey Design
rkendrick25
PRO
2
870
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
600
Thoughts on Productivity
jonyablonski
76
5.4k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
750
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
630
How to build a perfect <img>
jonoalderson
1
6.1k
Making the Leap to Tech Lead
cromwellryan
135
10k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
540
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
440
BBQ
matthewcrist
90
10k
Transcript
REFACTORING TO SIMPLICITY
MARCEL POCIOT BEYOND CODE @MARCELPOCIOT
WHAT DOES "SIMPLE" MEAN?
<?php use PHPUnit\Framework\TestCase; class StackTest extends TestCase { public function
testPushAndPop() { $stack = []; $this->assertSame(0, count($stack)); array_push($stack, 'foo'); $this->assertSame('foo', $stack[count($stack)-1]); $this->assertSame(1, count($stack)); $this->assertSame('foo', array_pop($stack)); $this->assertSame(0, count($stack)); } }
public function test_profile_photo_can_be_updated() { $file = new UploadedFile( public_path('img/color-logo.png'), 'color-logo.png',
'image/png', null, null, true ); Storage::shouldReceive('disk') ->once() ->with('public') ->andReturn($disk = Mockery::mock('StdClass')); $disk->shouldReceive('put'); $disk->shouldReceive('url')->once()->andReturn('/profile/photo'); $this->actingAs(factory(User::class)->create()) ->json('POST', '/settings/photo', [ 'photo' => $file, ]); $this->seeStatusCode(200); $this->seeInDatabase('users', [ 'photo_url' => '/profile/photo', ]); }
WHEN WE TEACH, WE START SIMPLE ▸ Focus on what
you want to teach ▸ Let the learner focus on one thing at a time ▸ ... it fits on a slide?
REALITY KICKS IN Real-life projects are not simple
DEVELOPERS LOVE COMPLEXITY
I'm not a begi er! I write my own framework!
— Every developer, at some point
L k at these 1000 LOC that I wrote. Only
I can understand it! — Senior Software Developer
None
None
None
SIMPLE CODE IS... ▸ Expressive ▸ Readable ▸ Understandable ▸
Self explanatory ▸ Reassuring ▸ Fun
IS SIMPLE CODE BETTER?
Yes
Thank you for coming to my TED talk
IS SIMPLE CODE FASTER TO WRITE?
Nope
None
None
None
TINKERWELL
FAMILIAR CODE != SIMPLE CODE
IS SIMPLER CODE BETTER TO TEST?
Usua y, Yes
class MetricController extends Controller { /** * List the metrics
for the given resource. * * @param \Laravel\Nova\Http\Requests\MetricRequest $request * @return \Illuminate\Http\Response */ public function index(MetricRequest $request) { return $request->availableMetrics(); } }
OKAY...SIMPLE IS GOOD AND ALL, BUT WHAT'S IN FOR ME?
▸ Simpler code is more readable ▸ Unsurprising code is
more maintainable ▸ Expressive code is fun !
HOW CAN I WRITE SIMPLE CODE?
KNOW WHAT SIMPLE CODE LOOKS LIKE
READ OTHER PEOPLES CODE
DO CODE REVIEWS
REFACTOR CODE AS IT GROWS
SIMPLE RULES FOR SIMPLER CODE
NAMING VARIABLES $list = MapSpot::orderBy("name")->get(); foreach($list as $key => $row)
{ $max = MapSpotSight::where("map_spot_id", "=", $row->id)->max("datetime"); $list[$key]->sights = MapSpotSight::where("map_spot_id", "=", $row->id) ->where("hides_at", ">", time()) ->where("datetime", "=", $max) ->orderBy("hides_at", "ASC") ->get(); }
USEFUL METHOD NAMES public function updateData($user, $project) { // ...
}
RETURN EARLY public function doSomething($someParameter, $someOtherParameter) { if ($someParameter ===
1) { if ($someOtherParameter === 1) { // do the actual work } } }
RETURN EARLY public function doSomething($someParameter, $someOtherParameter) { if ($someParameter !==
1) { return; } if ($someOtherParameter !== 1) { return; } // do the actual work }
Any inte igent f l can make things bi er,
more complex, and more violent. It takes a touch of genius—and a lot of courage to move in the opposite direction. — Albert Einstein
Any inte igent f l can make things bi er,
more complex, and more violent. It takes a touch of genius—and a lot of courage to move in the opposite direction. — E.F. Schumacher
SIMPLICITY TAKES COURAGE
None
None
SPEAKING OF LARAVEL
Route::get('user/(:num)', function($id) { // });
if (Auth::check()) { return "You're logged in!"; }
test('asserts true is true', function () { assertTrue(true); });
class SearchUsers extends Component { public $search = ''; public
function render() { return view('livewire.search-users', [ 'users' => User::where('username', $this->search)->get(), ]); } }
TAKE COURAGE ▸ Know what you can skip to make
things easy and simple ▸ Be brave enough to present your code ▸ Leave behind code that reflects you and your abilities
Now that my code is expressive, can I be replaced?
▸ Learn ▸ Read ▸ Care ▸ Test ▸ Communicate
None
Writing simple code is not simple But worth it
THANK YOU