Книги и журналы » Компьютерная литература » Программирование (книги)
Get Programming with ScalaГод издания: 2021
Автор: Sfregola Daniela
Издательство: Manning
ISBN: 9781617295270
Язык: Английский
Формат: PDF/ePub
Качество: Издательский макет или текст (eBook)
Интерактивное оглавление: Да
Количество страниц: 560
Описание: Get Programming with Scala is a fast-paced introduction to the Scala language, covering both Scala 2 and Scala 3. You’ll learn through lessons, quizzes, and hands-on projects that bring your new skills to life. Clear explanations make Scala’s features and abstractions easy to understand. As you go, you’ll learn to write familiar object-oriented code in Scala and also discover the possibilities of functional programming.
In Get Programming in Scala you will learn:
Object-oriented principles in Scala
Express program designs in functions
Use types to enforce program requirements
Use abstractions to avoid code duplication
Write meaningful tests and recognize code smells
Доп. информация:
https://github.com/DanielaSfregola/get-programming-with-scala[spoiler="Примеры страниц"]

[/spoiler]
[spoiler="Оглавление"]
Unit 0
HELLO SCALA! 1
Lesson 1 Why Scala? 3
Why Scala? 3
Scala and the JVM 5
Scala’s key features 7
Summary 9
Lesson 2 The Scala environment 10
The REPL installation 10
The REPL commands 12
The REPL code evaluation 13
Other development tools 16
Summary 16
Lesson 3 Scala Build Tool (sbt) 18
Why sbt? 18
sbt installation 19
sbt commands 20
Your first sbt project 21
sbt project structure 23
Summary 27
Unit 1
THE BASICS 29
Lesson 4 Values and variables 31
Values 32
Variables 34
Summary 36
Answers to quick checks 37
Lesson 5 Conditional constructs and loops 38
If-else construct 39
While loop 41
For loop 42
Summary 43
Answers to quick checks 44
Lesson 6 Function as the most fundamental block of code 45
Functions 46
Summary 51
Answers to quick checks 51
Lesson 7 Classes and subclasses to represent the world 52
Class 53
Subclass 56
Abstract class 58
Summary 60
Answers to quick checks 60
Lesson 8 The vending machine 62
Setting up the vending machine 63
Possible improvements to our solution 68
Summary 69
Unit 2
OBJECT-ORIENTED FUNDAMENTALS 71
Lesson 9 Import and create packages 73
Import an existing package 74
Create a package 76
Summary 78
Answers to quick checks 78
Lesson 10 Scope your code with access modifiers 79
Public, the default access modifier 80
Private 81
Protected 82
Which access level to use? 83
Summary 84
Answers to quick checks 84
Lesson 11 Singleton objects 86
Object 87
Executable object 89
Companion object 91
The apply method 92
Summary 95
Answers to quick checks 95
Lesson 12 Traits as interfaces 97
Defining traits 98
Extending traits 99
Sealed traits 102
Enumeration in Scala 3 103
Summary 104
Answers to quick checks 105
Lesson 13 What time is it? 106
What time is it? 106
Possible improvements to our solution 110
Summary 111
Unit 3
HTTP SERVER 113
Lesson 14 Pattern matching 115
If-else construct vs. pattern matching 116
Sealed pattern matching 119
Summary 121
Answers to quick checks 121
Lesson 15 Anonymous functions 123
Function vs. anonymous function 124
Concise notation for anonymous functions 126
Summary 128
Answers to quick checks 129
Lesson 16 Partial functions 130
Partial functions 131
Use case: Exception handling 134
Summary 136
Answers to quick checks 137
Lesson 17 HTTP API with http4s 138
An overview of http4s 139
A ping server using http4s 140
Summary 145
Answers to quick checks 145
Lesson 18 The time HTTP server 147
What time is it? 147
Possible improvements to our solution 153
Summary 154
Unit 4
IMMUTABLE DATA AND STRUCTURES 155
Lesson 19 Case classes to structure your data 157
Case class 158
Pattern matching and case classes 163
Case object 164
Summary 165
Answers to quick checks 165
Lesson 20 Higher order functions 166
Functions as parameters 167
Functions as return values 169
Summary 170
Answers to quick checks 171
Lesson 21 What is purity? 172
A definition of purity 173
Differentiating between pure and impure functions 175
Summary 177
Answers to quick checks 177
Lesson 22 Option 179
Why Option? 180
Creating an Option 180
Pattern matching on Option 185
Summary 186
Answers to quick checks 186
Lesson 23 Working with Option: map and flatMap 187
Transforming an Option 188
Summary 194
Answers to quick checks 195
Lesson 24 Working with Option: For-comprehension 196
For-comprehension on Option 197
Other operations on Option 201
Summary 202
Answers to quick checks 203
Lesson 25 Tuple and unapply 204
Tuples 205
Implementing the unapply method 209
Summary 212
Answers to quick checks 212
Lesson 26 Rock, Paper, Scissors, Lizard, Spock! 213
Implementing Rock, Paper, Scissors, Lizard, Spock! 214
Possible improvements to our solution 223
Summary 224
Unit 5
LIST 225
Lesson 27 List 227
Creating a list 228
Adding elements to a list 232
Pattern matching on a list 233
Summary 235
Answers to quick checks 236
Lesson 28 Working with List: map and flatMap 237
The map, flatten, and flatMap operations 238
For-comprehension 241
Summary 242
Answers to quick checks 243
Lesson 29 Working with List: Properties 244
Size of a list 245
Properties of the elements in a list 247
Summary 250
Answers to quick checks 250
Lesson 30 Working with List: Element selection 251
Selecting an element by its position 252
Finding an element with given features 253
Picking the minimum or maximum item 254
Summary 258
Answers to quick checks 258
Lesson 31 Working with List: Filtering 259
Dropping and taking elements 260
Filtering Items of a list 262
Removing duplicates 264
Summary 265
Answers to quick checks 265
Lesson 32 Working with List: Sorting and other operations 267
Sorting elements 268
Converting a list to a string 270
Sum elements of numerical sequences 272
Grouping elements by feature 273
Summary 275
Answers to quick checks 276
Lesson 33 The movies dataset 278
Download the base project 280
Parsing a movie entity 281
Printing query results 283
Querying the movie data set 284
Summary 289
Unit 6
OTHER COLLECTIONS AND ERROR HANDLING 291
Lesson 34 Set 293
Creating a set 294
Adding and removing elements 295
The map, flatten, and flatMap operations 296
For-comprehension 299
Summary 301
Answers to quick checks 301
Lesson 35 Working with Set 303
The Union, Intersection, and Difference operations 304
Other operations on Set 307
Summary 308
Answers to quick checks 308
Lesson 36 Map 309
Creating Map 310
Adding and removing elements 312
Merge and remove multiple entries 314
The map and flatMap operations 315
For-comprehension 318
Summary 319
Answers to quick checks 319
Lesson 37 Working with Map 322
Retrieving a value for a given key 323
Getting all keys and values 325
Other operations on Map 326
Summary 327
Answers to quick checks 328
Lesson 38 Either 329
Why Either? 330
Creating an Either 331
Pattern matching on Either 333
The map and flatMap operations 333
For-comprehension 337
Summary 338
Answers to quick checks 339
Lesson 39 Working with Either 341
Retrieving an Either value 342
Properties of an Either value 343
Summary 345
Answers to quick checks 346
Lesson 40 Error handling with Try 347
Creating a Try 348
Pattern matching on Try 352
The map, flatten, and flatMap operations 353
For-comprehension 356
Other operations on Try 357
Summary 358
Answers to quick checks 359
Lesson 41 The library application 361
Download the base project 362
Parsing a book entity 363
The business logic layer 367
Let’s give it a try! 372
Possible improvements to our solution 374
Summary 375
Unit 7
CONCURRENCY 377
Lesson 42 Implicit and type classes 379
Implicit parameters and values 380
Implicit resolution 385
Type classes 388
Summary 390
Answers to quick checks 391
Lesson 43 Future 393
Why Future? 394
Creating an instance of Future 395
Processing Future on completion 398
Summary 400
Answers to quick checks 400
Lesson 44 Working with Future: map and flatMap 402
The map, flatten, and flatMap operations 403
Summary 409
Answers to quick checks 410
Lesson 45 Working with Future: For-comprehension
and other operations 411
For-comprehension 412
Retrieving the first Future to complete 416
Summary 420
Answers to quick checks 421
Lesson 46 Database queries with Quill 423
Project setup 424
Connecting to the PostgreSQL server 428
Executing queries 429
Running generated queries 431
Summary 435
Answers to quick checks 435
Lesson 47 The quiz application: Part 1 438
Download the base project 439
Health check queries 441
Category queries 442
Question and answer queries 443
Let’s give it a try! 446
Summary 450
Unit 8
JSON (DE)SERIALIZATION 451
Lesson 48 JSON (de)serialization with circe 453
Project setup 454
JSON serialization: From instance to JSON 455
JSON deserialization: From JSON to instance 458
Summary 461
Answers to quick checks 462
Lesson 49 Lazy evaluation 463
By-name parameters 464
Lazy values 466
Summary 470
Answers to quick checks 470
Lesson 50 The IO type 472
Why IO? 473
Project setup 475
Synchronous side effect 476
Asynchronous side effect 478
Summary 481
Answers to quick checks 482
Lesson 51 Working with the IO type 484
The map and flatMap operations 485
For-comprehension 488
Parallel execution 489
Summary 492
Answers to quick checks 492
Lesson 52 Testing with ScalaTest 494
Project setup 495
Your first test 495
Asynchronous testing 498
Summary 500
Answers to quick checks 501
Lesson 53 The quiz application: Part 2 504
Download the base project 505
Generic endpoints 506
Displaying the available categories 508
Creating a quiz 510
Answering a quiz 513
The HTTP server 516
Writing tests 518
Let’s give it a try! 521
Summary 523
Index 525
[/spoiler]