Wednesday, October 18, 2017

Vitae

‘Vitae’ is a free One Page WordPress layout providing you with a clean, long-scrolling Curriculum Vitae. Features include intro image, biography, work history, networks and contact details.

Please note: Vitae is a layout in the free FullSingle WordPress Plugin. This plugin provides One Page layouts that work with any existing WordPress theme 🙌

Vitae installation instructions: (watch the simple setup video)
  1. Upload and activate the FullSingle WordPress plugin (in your plugin section)
  2. Activate the bonus recommended plugins
  3. Create a new Page (not Post) and give it a title
  4. Select the Page Builder tab top-right of your content edit area
  5. Click the Layout button, then select and insert the Vitae layout
  6. In the Page Attibutes block (to the right), set the Template to FullSingle - Vitae
  7. Edit accordingly then click Publish
  8. Open up your Theme Customizer to change colors and access Layout specific tutorials

Full Review | Direct Link


by Rob Hope @robhope via One Page Love

Kotlin From Scratch: Abstract Classes, Interfaces, Inheritance, and Type Alias

Kotlin is a modern programming language that compiles to Java bytecode. It is free and open source, and promises to make coding for Android even more fun.  

In the previous article, you learned more about Kotlin properties such as late-initialization, extension, and inline properties. Not only that, you also learned about advanced classes such as data, enum, nested, and sealed classes in Kotlin. 

In this post, you'll continue to learn about object-oriented programming in Kotlin by learning about abstract classes, interfaces, and inheritance. For a bonus, you'll also learn about type aliases. 

1. Abstract Classes

Kotlin supports abstract classes—just like Java, these are classes which you never intend to create objects from. An abstract class is incomplete or useless without some concrete (non-abstract) subclasses, from which you can instantiate objects. A concrete subclass of an abstract class implements all the methods and properties defined in the abstract class—otherwise that subclass is also an abstract class!

We create an abstract class with the abstract modifier (similar to in Java). 

Note that not all members have to be abstract. In other words, we can have method default implementation in an abstract class. 

Here we created the non-abstract function fullName() in an abstract class Employee. Concrete classes (subclasses of the abstract class) can override an abstract method's default implementation—but only if the method has the open modifier specified (you will learn more about this shortly). 

We can also store state in abstract classes. 

Even if the abstract class doesn't define any methods, we need to create a subclass before we can instantiate it, as in the example below.

Our Programmer class extends the Employee abstract class. In Kotlin we use a single colon character (:) instead of the Java extends keyword to extend a class or implement an interface. 

We can then create an object of type Programmer and call methods on it—either in its own class or the superclass (base class).  

One thing that might surprise you is that we have the ability to override a val (immutable) property with var (mutable). 

Make sure you use this functionality wisely! Be aware that we can't do the reverse—override a var property with val

2. Interfaces

An interface is simply a collection of related methods that typically enable you to tell objects what to do and also how to do it by default. (Default methods in interfaces are a new feature added to Java 8.) In other words, an interface is a contract that implementing classes must abide by. 

An interface is defined using the interface keyword in Kotlin (similar to Java). 

In the code above, we've declared a StudentRepository interface. This interface contains two abstract methods: getById() and getResultsById(). Note that including the abstract keyword is redundant in an interface method because they are already abstract implicitly. 

An interface is useless without one or more implementers—so let's create a class that will implement this interface. 

Here we created a class StudentLocalDataSource that implements the StudentRepository interface.

We use the override modifier to label the methods and properties we want to redefine from the interface or superclass—this is similar to the @Override annotation in Java.

Note the following additional rules of interfaces in Kotlin:

  • A class can implement as many interfaces as you want, but it can only extend a single class (similar to Java).
  • The override modifier is compulsory in Kotlin—unlike in Java. 
  • Along with methods, we can also declare properties in a Kotlin interface. 
  • A Kotlin interface method can have a default implementation (similar to Java 8). 

Let's see an example of an interface method with a default implementation.

In the preceding code, we added a new method delete() with a default implementation (though I did not add the actual implementation code for demonstration purposes). 

We also have the freedom to override the default implementation if we want.

As stated, a Kotlin interface can have properties—but note that it can't maintain state. (However, remember abstract classes can maintain state.) So the following interface definition with a property declaration will work.

But if we try to add some state to the interface by assigning a value to the property, it will not work.

However, an interface property in Kotlin can have getter and setter methods (though only the latter if the property is mutable). Note also that property in an interface cannot have a backing field. 

We can also override an interface property if you want, so as to redefine it. 

Let's look at a case where we have a class implementing multiple interfaces with the same method signature. How does the class decide which interface method to call?

Here we have two interfaces that have a method with the same signature funD(). Let's create a class that implements these two interfaces and overrides the funD() method. 

The compiler is confused about calling the super.funD() method because the two interfaces that the class implements have the same method signature. 

To solve this problem, we wrap the interface name for which we want to call the method in angle brackets <InterfaceName>. (IntelliJ IDEA or Android Studio will give you a hint about solving this issue when it crops up.)

Here we are going to call the funD()  method of InterfaceA. Problem solved! 

3. Inheritance

A new class (subclass) is created by acquiring an existing class's (superclass) members and perhaps redefining their default implementation. This mechanism is known as inheritance in object-oriented programming (OOP). One of the things that make Kotlin so awesome is that it encompasses both the OOP and functional programming paradigms—all in one language.

The base class for all classes in Kotlin is Any

The Any type is equivalent to the Object type we have in Java. 

The Any type contains the following members: equals(), hashcode(), and also toString() methods (similar to Java). 

Our classes don't need to explicitly extend this type. If you don't explicitly specify which class a new class extends, the class extends Any implicitly. For this reason, you typically don't need to include : Any in your code—we do so in the code above for demonstration purposes. 

 Let's now look into creating classes in Kotlin with inheritance in mind. 

In the code above, the GraduateStudent class extends the superclass Student. But this code won't compile. Why? Because classes and methods are final by default in Kotlin. In other words, they cannot be extended by default—unlike in Java where classes and methods are open by default. 

Software engineering best practice recommends that you to begin making your classes and methods final by default—i.e. if they aren't specifically intended to be redefined or overridden in subclasses. The Kotlin team (JetBrains) applied this coding philosophy and many more development best practices in developing this modern language. 

For us to allow subclasses to be created from a superclass, we have to explicitly mark the superclass with the open modifier. This modifier also applies to any superclass property or method that should be overridden by subclasses.

We simply put the open modifier before the class keyword. We have now instructed the compiler to allow our Student class to be open for extension. 

As stated earlier, members of a Kotlin class are also final by default. 

In the preceding code, we marked the schoolFees function as open—so that subclasses can override it. 

Here, the open schoolFees function from the superclass Student is overridden by the GraduateStudent class—by adding the override modifier before the fun keyword. Note that if you override a member of a superclass or interface, the overriding member will also be open by default, as in the example below:

Even though we didn't mark the schoolFees() method in the GraduateStudent class with the open modifier, we can still override it—as we did in the ComputerScienceStudent class. For us to prevent this, we have to mark the overriding member as final

Remember that we can add new functionality to a class—even if it's final—by the use of extension functions in Kotlin. For a refresher on extension functions, check out my Advanced Functions in Kotlin post. Also, if you need a refresher on how to give even a final class new properties without inheriting from it, read the section on extension Properties in my Advanced Properties and Classes post. 

  • Kotlin
    Kotlin From Scratch: Advanced Functions
    Chike Mgbemena
  • Kotlin
    Kotlin From Scratch: Advanced Properties and Classes
    Chike Mgbemena

If our superclass has a primary constructor like this:

Then any subclass has to call the primary constructor of the superclass. 

We can simply create an object of the GraduateStudent class as usual:

If the subclass wants to call the superclass constructor from its secondary constructor, we use the super keyword (similar to how superclass constructors are invoked in Java). 

If you need a refresher on class constructors in Kotlin, kindly visit my Classes and Objects post. 

4. Bonus: Type Alias

Another awesome thing we can do in Kotlin is to give a type an alias. 

Let's see an example.

In the class above, we can assign the String and Int types for the Person properties aliases using the typealias modifier in Kotlin. This modifier is used to create an alias of any type in Kotlin—including the ones you have created. 

As you can see, we have created an alias Name and Age for both the String and Int types respectively. We have now replaced the firstName and lastName property type to our alias Name—and also Int type to Age alias. Note that we didn't create any new types—we instead created an alias for the types. 

These can be handy when you want to provide a better meaning or semantic to types in your Kotlin codebase. So use them wisely! 

Conclusion

In this tutorial, you learned more about object-oriented programming in Kotlin. We covered the following:

  • abstract classes
  • interfaces 
  • inheritance
  • type alias

If you have been learning Kotlin through our Kotlin From Scratch series, make sure you have been typing the code you see and running it on your IDE. One great tip to really grasp a new programming language (or any programming concept) you're learning is to make sure you don't just only read the learning resource or guide, but also type the actual code and run it!

In the next tutorial in the Kotlin From Scratch series, you'll be introduced to exception handling in Kotlin. See you soon!

To learn more about the Kotlin language, I recommend visiting the Kotlin documentation. Or check out some of our other Android app development posts here on Envato Tuts!

  • Android SDK
    Java vs. Kotlin: Should You Be Using Kotlin for Android Development?
    Jessica Thornsby
  • Android SDK
    Introduction to Android Architecture Components
    Tin Megali
  • Android SDK
    Get Started With RxJava 2 for Android
    Jessica Thornsby


by Chike Mgbemena via Envato Tuts+ Code

Seismic Survey

Long-form Journalism One Pager explaining the importance of Seismic Surveying. Nice touch with the parallax effect on the whales as you scroll down 🐋

Full Review | Direct Link


by Rob Hope @robhope via One Page Love

Meshugge

Launching Soon page for fashion event Meshugge featuring a unqiue zoom/tunnel effect controlled by your cursor.

Full Review | Direct Link


by Rob Hope @robhope via One Page Love

The Broke Designer's Guide to Making Money Online - #infographic

As the old song goes, money makes the world go ‘round. Even if you’re a full-time designer with a day job, it never hurts to have a little extra money in your pocket. Whether you’re saving for up for that end-of-year vacation or need to pay rent like, yesterday, these days there are a few options...

[ This is a content summary only. Visit our website http://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Web Desk via Digital Information World

#180: 6 Myths of Progressive Web Apps

Mobile Dev Weekly October 18, 2017   #180
Chris Brandrick recommends
6 Myths of Progressive Web Apps — Busting some of the common myths surrounding PWAs.
Peter O'Shaughnessy
Chris Brandrick recommends
The Web Share API Is Here: Here's How to Use It — This JavaScript API, added in Chrome 61, lets you implement native sharing capabilities from your mobile web app (it was previously only available on native platforms).
Mark Muskardin
Sponsored
SwiftFest 2017 Conference - Coming to Boston in November — SwiftFest 2017 is a community-driven event that will expose you to new perspectives about the Swift programming language and the iOS development ecosystem. Register today using the promo code "SWIFT3" to receive a 10% discount off the ticket price.
swiftfest

Chris Brandrick recommends
Reactive Programming for the New Mobile Stack — Four principles for the ‘new mobile stack’: Event-driven, data flow, data sticks and pragmatic logic.
Alexander Stigsen
Holly Schinsky recommends
Google Introduces Android Instant Apps SDK 1.1 — Android Instant Apps allows Android users to run your apps instantly, without installation.
Google
Sponsored
The Essential Guide to Queueing Theory — Queueing theory is one of the best ways to boost performance. This ebook demystifies the subject without requiring pages full of equations.
VividCortex

Mobile Web
Brian Rinaldi recommends
The Argument for AMP: Lessons From 10 Case Studies — A guide to Google Accelerated Mobile Pages (AMP) including case studies from ten brands.
Eric Enge
Brian Rinaldi recommends
Responsive SVG Sprite Animation that Adjusts Based on Viewport — An example of a complex SVG sprite animation that adjusts to the viewport size.
Sarah Drasner
Holly Schinsky recommends
Ember.js: The Perfect Framework for Web Applications — Ember.js lets you scaffold and build complex front-end web apps quickly. Graham Cox explores this popular, batteries-included JavaScript framework.
SitePoint
Brian Rinaldi recommends
Naming Things In CSS Grid Layout — The various ways that you can name lines and areas in CSS Grid Layout to enable easier placement of items by name rather than number.
Rachel Andrew
Chris Brandrick recommends
Creating Awesome SPAs With React
Aman Khalid
Brian Rinaldi recommends
Safari's Implementation of 'srcset' Is Buggy, Rendering The Whole Feature Basically Useless — The srcset attribute can be a great feature when it works, but it appears to fail in some fairly common use cases in Safari.
Ben Halpern
Brian Rinaldi recommends
DevTools Tips for Progressive Web Apps — Some tips on using Chrome to debug issues related to PWAs.
Raymond Camden
Hybrid Apps
Brian Rinaldi recommends
Ionic App Generator — A new utility for generating Ionic-based applications, Ionic App Generator (macOS and Windows).
Chris Griffith
Holly Schinsky recommends
Ionic Lazy Loading Bonuses — How to take advantage of Lazy Loading in your Ionic 3 apps.
Ryan Corbin
Native Development
Peter Cooper recommends
Building Shopify Mobile with Native and Web Technology — Always good to see a case study from a company doing well.
Shopify Engineering
Brian Rinaldi recommends
Add Firebase Authentication to Your Android App in 7 Minutes
Ekene Eze


by via Mobile Dev Weekly

LinkedIn Website Demographics: What Marketers Need to Know

Want more information on people who visit your website? Did you know LinkedIn can help? LinkedIn Website Demographics provides professional insights about your website visitors and allows you to remarket to them through LinkedIn ads. In this article, you’ll learn how to set up and use LinkedIn’s Website Demographics for remarketing. #1: Set Up LinkedIn [...]

This post LinkedIn Website Demographics: What Marketers Need to Know first appeared on .
- Your Guide to the Social Media Jungle


by Kristi Hines via