First thing first, it always feels good to know that even if your work is small but it’s making a huge difference in someone’s life. 🙂 There are millions of smartphone users all around the world with some sort of disability. Enabling accessibility into the software system ease them in interacting with it.
And on the other hand, if you’re working for any government agency you have to implement it because of 508 compliance (which says that any technology or software product must be accessible to all users).
– Vision: a vision challenge that makes focusing difficult, color blindness or total blind. – Hearing: difficulty hearing sound, partial hearing loss or maybe deaf. – Physical and motor skills: difficulty when it comes to tapping the interface or holding a device. – Learning and Literacy: hard to understand a complex user interface or hard to remember a sequence of step to do a certain task.
Image from Apple.
What is VoiceOver?
A screen reading tool that helps the user to interact with the application without seeing the screen. The feature is designed for those who have vision problems. Navigate to Settings/Accessibility/VoiceOver.
Enable the VoiceOver to try this out. – Single tap: Tap anywhere, VoiceOver will start speaking information as per the accessibility attributes (find more later). – Swipe right or left: Try swipe right/left VoiceOver will navigate you through all items on the screen while reading them aloud. Right for forward/down and Left for reverse/up. -Double Tap: is to tap on a selected item. – Single swipe down: is to spell out the focused item. – Three finger swipe: For page views to navigate forwards or backward
Core attributes that VoiceOver will use to provide information to the user. – Label: way to identify the view (like settings button, profile image) VoiceOver will speak the same when the item will be selected. – Traits: way to identify the element state, usage or behaviour (like a button is selected.) – Hint: way to describe the action of an element (like Go to detail). – Frame: frame of the element within the screen. – Value: The value of element like a slider bar. – AccessibilityLanguage: The language code that the element label value, hint should be spoken.
How to debug accessibility attributes?
Accessibility inspector is a tool given by Apple to debug your app (Navigate to Xcode/Open Developer Tool/Accessibility Inspector). Where developer can choose the target, enable the pointer to debug the view.
Animation or layout changes are a visual feedback to the user as a response of the action taken, Use announcements notification to provide an update (other options are layoutChanged, screenChanged delegates).
Target Touch Size?
As per Apple human interface guidelines it is recommended to maintain a tappable area of 44x44pt (minimum) for all controls in the application.
What is Dynamic Type?
Functionality that allows the users to dynamically adjust the size of text, images (choose their preferred text size). iOS app will adopt the text/image size as per user preference. (Apple Developer documentation)
Setup Smart Invert Colors?
Need to set `accessibilityIgnoresInvertColors` property to enable or prevent a control from inverting it’s colours. (Navigate to Setting/General/Accessibility/Display Accommodations/Invert Colors).
Overview? With iOS 13 and above people can adopt a dark appearance where Apple docs says user can use settings to make their devices automatically switch to dark mode when ambient is low and this will help you to put focus on your content.
Development Environment? As as iOS developer you’ve to use Xcode 11 with iOS 13 SDK and above, iOS will automatically update system controls such as switches, collection-views etc. If you are migrating your existing app to dark in that case you will have to adapt the colours.
How to define colours for each mode?
System Colours? iOS 13 SDK includes new system colours so if you adapt these system colours your app will automatically support dark and light mode, You can use it via Storyboard as well as programmatically (Some example below)
Custom Colors? Yes it’s strongly recommended by Apple that use system colours to provide better UX and also to make sure the consistency across apps but using the asset you can define you colour choices. Once you define iOS will take care everything for you.
How to define Image for each mode?
Using the Assets you can specify which image you want to use for dark VS any other mode and just define the image and let iOS take care for you.
How to detect dark mode programmatically?
On Load Detection? We can use overrideUserInterfaceStyle to check which mode is currently running on user device (Just make sure, this property only available on iOS 13 and above)
Runtime Detection? Can use traitCollectionDidChange to observe the changes, It is important to remember that trait-collection may be called for other trait changes (such as device rotation)
Set Dark Mode for Specific Screen? Yes you can, this property overrideUserInterfaceStyle is available for you to use (only iOS 13 and above)
How to support WKWebView? Just need to create variable for the color and need to handle this in CSS.
After Integrating this change you can use Safari to test (First you need to enable the developer menu option in Sarafi, Preferences, Advanced). Open wen inspector (using Command + Options + I) and you will see this screen with the option to toggle light/dark mode.
Swift is fast, safe and expressive language to code with great full stack potential and community support. According to Apple, it’s 2.6 times faster than Objective C (As a Swift Developer I agree on this too 🙌). It’s 6th most loved language on StackOverflow.
ABI Background As a developer, I hope sometimes you also felt that Swift is not mature enough as every year major changes are being introduced. One of the key problems articulated by a lot of developers is “Lack of backward compatibility” and you have to choose one Swift version for your Xcode projects (Version lock). Resulting in with a new Swift release you have to make changes in your existing code.
What is ABI? ABI stands for Application Binary Interface. During runtime, Swift program interacts with other libraries through ABI (low-level set of protocols for memory representation, function calls, and access). So when I say ABI not stable it means that each binary is building its own version of Swift Dynamic Library inside it. Now the Swift 5 is ABI Stable which means if I build two apps, one using Swift 5.0 and another using Swift 5.2, both will use Swift ABI embedded in the iOS Operating System.
Why ABI Stability matters a lot?
Compatibility: which means new compilers can compile your old Swift code which means no more migration pain.
Bundle Size: It will reduce the build size because of no Swift standard Library in your Framework folder.
Binary framework and runtime compatibility which enables the framework distribution as a binary which will work across multiple Swift versions.
Conclusion: Swift is the future for Apple ecosystem and now it’s ABI stable which means, in other words, it is like write once and use everywhere.
Important Starting in iOS 8.0 and OS X 10.10, use WKWebView to add web content to your app. Do not use UIWebView or WebView.
WebKit was introduced in iOS 8 but it was released with an error which caused in a runtime crash, If you are using Xcode 9/10, your project configuration support less than iOS 11 and if you are trying to add WKWebView using interface builder. Xcode immediately shows a compile-time error.
WKWebView before iOS 11.0 (NSCoding Support was broken in the previous version)
Although WKWebView was introduced in iOS 8, there was a bug in –[WKWebView initWithCoder:] that was only fixed in iOS 11.
Resolution is you must add WKWebView through code (Only if you are supporting below iOS 11). That actually sounds strange.
Another solution is to change the Interface Builder Document Builds for the option to iOS 11 and later (If you’re migrating from older target to iOS 11 and still getting the same error).
When the user taps an on App icon, iOS creates an instance of UIApplication which runs on the main thread. This main thread processes all UI events such as touch, location updates etc.
After app launched successfully, it becomes available for the user to do interactions with it and every single interaction which known as an event is processed in a FIFO manner.
Now while events are being processed there may come some UI update requests which aren’t get fulfilled immediately. Instead, the system waits until the existing process finishes and the next redraw cycle comes. There is a periodic interval between the event processing and UI layout handling. The setLayoutNeeded() and layoutIfNeeded are two UIView’s methods here to ask the system for updating the view with new changes.
The setNeedsLayout() tells the system that you want the view and all it’s subviews to be redrawn in the update cycle.
Here is What Apple’s doc says on this, “Call this method on your application main thread when you want to adjust the layout of a view’s subviews. Note that it returns immediately (Async call) because it does not force an update, it waits for the next update cycle”.
Whereas layoutIfNeeded() is an async call which tells the system that you want the view and it’s subviews to be redrawn immediately without waiting for the next update cycle.
UIView have one more method named layoutSubviews() which you can use for your own implementation to set the frame of your view directly by overriding it. And since it’s default implementation uses the constraints you have given to determine it’s size and positions to get the frame, you should override it unless autoresizing and constraint behavior is not working for you as expected.
In short use setNeedsLayout(), if you are okay with the system to update it in the next upcoming update cycle and use layoutIfNeeded() if you want it to be updated immediately.
Is it more important for the software system to work or is it more important to be easy to change? If you ask the business managers they will say work is more important, some developers also go along with this attitude but that’s the wrong attitude.
Why the wrong attitude?
If you give me a program that works perfectly but impossible to change, it means it won’t work when the requirements change.
If you give me a program that does not work but easy to change, it means I can make the change to make it work.
If you’re a programmer with the attitude (1.) then one day your system will reach to the point where the change will be impractical (cost of change will be unaffordably high).
Eisenhower said, I have two kinds of problems, the urgent and the important, where the urgent are not important and the important is never urgent.
when it comes to software, The first value of software is behavior, is urgent but not always important. The second value is architecture, is important but never urgent. Of course, some things are not urgent and not important.
Urgent and important
Not urgent and important
Urgent and not important
Not urgent and not important.
Mistakes that business managers and developer make is to elevate items in position 3 to 1. It means they always fail to separate those features that are urgent but not important from those features that are really urgent and important and this failure leads to ignoring the important architecture of the system in favor of the unimportant features of the system.
So if you are a software developer, you are hired to maintain the quality and structure of the system and only you know the importance of the architecture.
Thanks for reading it, if you want to read in more detail, buy “Clean Architecture by Robert C. Martin”
The design is more often seems to when it comes to structures and low-level decisions whereas Architecture is often used in the context of something at the high level where we can see how components are connected with each other. But for starters, there is no different at all.
What is the GOAL of good software design?
The goal of software architecture is to minimize the Human Resources required to build and maintain the required system (By Uncle Bob Martin)
Basic fundamentals measure the design?
The measure of design quality is simply the measure of the effort required to meet the needs of the customer if the effort is low and stays same through the lifetime, System design is good else it’s bad.
The Signature of a system design mess?
Developer point of view
The graph says developers started with nearly 100% of productivity but with each release, their productivity going down
Executive point of view? Release 1 was delivered with a few hundred thousand payrolls and by the time of 5 release, it’s going to touch $500,000.
What is going wrong?
The moral of the story says everything in one line: “Slow and steady wins the race”. Yes, it all because of overconfidence. Everyone wants to hit the market first or release the app asap with the statement “We can clean it up later” and they can’t go back for cleaning the things up because now we have the new feature, new release so maybe next time, next time and next time.
The only way to go fast is to go well.
To take the software architecture seriously we have to think and need to know what good software architecture is, compare the different architecture with the requirements.
Thanks for reading it, if you want to read in more detail, buy “Clean Architecture by Robert C. Martin”
Let’s say you work as a company secretary and your job is to take the phone calls, manage meetings etc. Every time the phone rings, you have to stop whatever you are doing. A property of a program that allows tasks to run in overlapping time periods.
Parallelism, allows 2 or more tasks to run at the same time (Only if the machine has the multiprocessing capability). You asked your boss and he hired a clerk for taking the call. It looks very simple but concurrency introduces a few problems like the Race condition,
Race Condition, Suppose you have $500 in your bank account, at the same time when you withdraw $200 someone transferred $300 or maybe in simple words same time 2 transaction happened for withdrawing $500.
Mutual Exclusion (Mutex), Solution for the Race condition. Now, whenever some transaction starts it locks the account. if some transaction is going on with your account you cannot withdraw. But next problem is nobody wants to wait every time when there’s is something going on. Semaphore is the modified solution for Mutex.
Semaphore (Improper use of Semaphore will give improper results)
Binary Semaphore (Range is from 0 to 1), Idea is to give specific priority to different types of transaction. Withdraw request has a higher priority than bank transfer. So when you withdraw, another transaction for transfer will stop and it will resume once withdraw is completed. (As simple as that, 1 = ongoing transaction, 0 = waiting) Also known as integer semaphore.
Counting Semaphore (Range is from -∞ to +∞), Allow more than one process running at the same time. Let’s suppose you’re a key room manager where you have 30 keys if lockers are full users have to wait in the queue. when someone has done they will hand over the key to the first person in the queue.
Deadlock, Another common issue in concurrency modal. Let’s assume user a transferred amount to b and at the same time user b transfer the amount to the user a. both transactions are waiting to complete another one as they can’t access the locked account.