My experiences at confoo day 2
5 Unit Testing Facts I Wish I’d Known 7 Years Ago - Dror Helper
“I started using unit tests eight years ago and failed miserably. It took me two years and the right company to start over and learn how to properly use unit tests and TDD as development tools. But it wasn’t always clear sailing. As I progressed, I found more than my fair share of pitfalls and blind alleys, as well as a fair amount of success. In this talk, I’ll cover the essential facts I learned over the years about unit testing.”
- Have the right environment
- Build server & Dev machines
- Class != Unit
- Unit of work is a undefined abstract – no good definition
- Not all tests are unit tests
- Integration tests -> test system wide functions
- Code duplication is ok (usually)
- Readability > DRY
- Unit testing is not about writing tests
- Understand why a test failed
- Find out how to fix the problem
High Value Apps are Moving to the Desktop - Boris Mann
“Developers, designers and others whose day job is spent using a professional desktop operating system are demanding more than having their apps trapped in browser tabs. We’ll talk about how high value apps such as Slack, Microsoft Visual Studio Code, Brave browser are using web technologies but run on the desktop. We’ll talk a bit about the tech (Electron.js and friends) but the focus will be on the usability, value, and what this trend means.”
Using electron to build native desktop apps. Slack, Visual studios Code.
High Value apps lost in tabs
- Focus: alt tab
- Capabilities: access native desktop functionality – shortcuts notifications, menu bar, spotlight
- Convenience: from menu bar to “always there”
Electron created by github for atom.io editor.
- Automatic updates
- Native menus & notifications
- App Crash reporting
- Debugging & profiling
- Windows installer
Quip wiki/note taking app
Chromium + nodejs + native APIs = Electron
How is it not like webdev
- Targeting only a single browser – the latest version of chromium
- Can have all assets and code locally
- Or mix and match local(large!) assets and remote api calls and assets
- In many ways, a more controlled environment
- Keytar for storing keys, hashed
You Don’t Know Node.js - Vance Lucas
“Node.js can be a powerful platform used in the right situations, but it also has more footguns than PHP does for new developers. Asynchronous programming style, concurrency issues, error handling, the event loop, and no default timeouts for HTTP requests or network calls will give new developers more than their fair share of troubles. This talk gives a thorough introduction to node.js and the event loop model, and covers common pitfalls to avoid.”
How the event loop works- http://latentflip.com/loupe/
- Can use other threads
- Network i/o
- File system access
- Web workers
Call back queue only goes to call stack if it’s empty. (settimeout, button callbacks). Queue gets too full, tab crashes. Dont block the event loop. Async: false is bad.
- Nginx (handle all the static assets)
- Runs forever
- Does not cleanup/tear down
- Need to watch memory
- Single threaded
Unbreakable Unit Tests - Michael Simonson
“How often have you rewritten your unit tests from scratch just because the code it was testing evolved slightly? In this session we will explore some unit testing techniques from other languages to produce more robust tests in PHP. You’ll never have to send your unit test to the trashcan again.”
When to test? Only on projects that you want to succeed
UI, slow, expensive.
Unit, fast, cheaper – no dependencies.
Existing code dependencies
- Hard to setup across machines
- Sometimes subtle (time)
Mutation testing – humbug? – randomly changes logic in code to verify it was covered by tests.
AAA – Arrange, Act, Assert.
Arrange – setup for test.
Act- Running the code.
Assert – making assertion about the behaviour.
Practical PHP Deployment with Jenkins - Adam Culp
“Developers love to “automate all the things,” but where to start? What tools exist, and what can be automated? Without unit tests, can it still benefit to automate? We will show how a PHP application pulled from Git, complete with unit tests, composer dependency management, and package creation, can be repeatedly deployed flawlessly using Jenkins. Then see how “Dev” and “Ops” are supported if the application breaks through automated rollbacks.”
Judo belt gets “dirtier” from all the practice.
Don’t run composer in production.
Phing to create password files.
Chef, puppet, zend server.
- Build pipeline
- Clone workspace SCM
- X CloudBees Folder
- Copy Artifact
- Delivery Pipeline
- Join Plugin
- PostBuild Script
Master branch should always be ready to deploy.
Database Architecture for SaaS - Shawn Hooper
“There are many considerations you should take into account when designing the database architecture of a Software-as-a-Service (SaaS) product. Scalability, geography, security, ease of implementation and deployment, performance, and data retention are all factors to consider. We’ll explore these issues, look at single and multi-tenant database models, and discuss options in both relational SQL and non-relational noSQL worlds.”
- All users/clients share one database
- Scalability limited by storage and system resources
- Code complexity: Queries need to include client ID
- Security concerns.
- Also Means everyone gets upgraded at the same time.
- Potential for more bugs to reach all users
Single Tenant Model
- Separate for each tenant
- Self Services: More difficult. Requires the system to be able to create a new database for each new tenant.
- Free trial on a separate server.
- Security: Separation of data.
- Don’t need tenant ID in every query.
- Can roll out partial upgrades.
- Micro services model.
- Database separated by function.
- Less data stored in each service, limited potential for loss in the event of a breach.
- Multiple database connection to maintain (multiple APIs too).