Oreilly - Best Practices in Scala Programming
by Joshua Backfield | Released June 2016 | ISBN: 9781491959268
Anyone starting a project in Scala, expanding a Scala project, or looking to establish coding standards as a means for helping junior Scala programmers come up to speed, will value this overview of Scala best practices by Scala expert Joshua Backfield.Backfield's extensive experience in both object-oriented programming and functional programming make him a Scala authority. He has ported multiple native C applications to Scala, introduced many coworkers to Scala, and taught them the underlying functional programming concepts. He uses that experience to offer a set of Scala guidelines that should make your Scala code base as great as it can be.Review and master the coding standards used by expert Scala programmersLearn methods for ensuring that junior level programmers adhere to coding standardsUnderstand the norms for var and val usages and functions as objectsReview standards for immutable vs. mutable data structures and for pattern matchingMaster axioms in OOP for use cases, instance methods, and mixing vs. deep inheritanceLearn standards for advanced features like avoiding postfix notation and dynamic typingUnderstand best practices for syntax, concurrency, and self-documenting codeJoshua F. Backfield, author of the O'Reilly title Becoming Functional: Steps for Transforming Into a Functional Programmer, has been a Senior Software Engineer at SPARC and Dell SecureWorks. In addition to Scala, his specialties include: Linux, LiftWeb, Squeryl, Java, Spring MVC, Spring, JAX-WS, C, C++, Perl, MySQL, BSD Socket, Functional Programming, and Akka. He holds an M.S. in Computer Science from DePaul University and a B.S. in Electronic Systems from Southern Illinois University-Carbondale. Show and hide more Publisher resources Download Example Code
- Introduction
- Welcome To The Course 00:01:50
- About The Author 00:00:45
- Using Val And Var
- Overview Of Val And Var 00:01:08
- Common Usages Of Val 00:05:45
- Common Usages Of Var 00:05:28
- Using Var Vs. Mutable Datatypes 00:07:18
- Using Var In Loop Contexts 00:05:53
- Functions As Objects
- Storing Defs Inside Of Vars 00:04:01
- Storing Functions In Lists And Maps 00:05:26
- Abstract Function Bodies When Possible 00:06:21
- Functions Should Be Testable 00:04:45
- Immutable Vs. Mutable
- Using Mutable Data Structures 00:05:14
- Using Immutable Data Structures 00:04:48
- Pattern Matching
- Do Not Pattern Match For All Statements 00:03:09
- Cover All Outcomes Of A Pattern Match 00:05:07
- Prefer Value Matches Over Guards When Possible 00:05:16
- Prefer To Map/Filter Over An Option Rather Than Pattern Matching 00:06:38
- Prefer Pattern Matching To Type Casting 00:04:41
- Lazy Val
- Cost Of A Lazy Val 00:05:51
- Common Usages Of Lazy Val 00:05:12
- Using A Factory And Lazy Val Pattern 00:03:19
- Oop
- Useless Traits 00:04:19
- Using Case Classes Effectively 00:02:47
- Instance Methods Invoking Static Methods 00:03:32
- No Classes Inside Of Package Objects 00:03:27
- Prefer Mixing Over Deep Inheritance 00:07:48
- Syntax
- Do Not Use The Return Keyword 00:05:29
- Do Not Use Exceptions For Validation And Flow Of Control 00:08:56
- Do Not Use Null 00:04:07
- Do Not Use Option.Get 00:03:36
- Explicit Return Types 00:04:27
- Concurrency
- Prefer The Actor Model Over Manual Runnable/Thread 00:05:44
- Always Prefer A Single Producer 00:05:22
- Thread Safety Of Public Apis 00:04:31
- Blocking I/O On A Separate Thread Pool 00:09:46
- Futures Are Not The End Answer 00:04:56
- Prefer An Ask Over Exposing Internal Actor Workings 00:05:39
- Actors Should Only Accept Data 00:06:36
- Advanced Language Features
- Avoid Postfix Notation 00:05:41
- Avoid Implicit 00:09:44
- Avoid Complex Structural Typing 00:06:17
- Avoid Dynamic Typing 00:07:11
- General Programming
- Proper Naming Of Variables And Functions 00:04:07
- Long Line Splitting 00:07:48
- Return Types For Methods 00:03:04
- Catch Exceptions When Possible 00:03:15
- Self-Documenting Code 00:04:43
- Conclusion
- Wrap Up And Thank You 00:01:04
Show and hide more