Skip to content

Instantly share code, notes, and snippets.

View ridhoperdana's full-sized avatar
🎯
Focusing

Ridho Perdana ridhoperdana

🎯
Focusing
View GitHub Profile
@ridhoperdana
ridhoperdana / extractfunction.go
Last active December 30, 2020 05:20
example of don't repeat yourself
package main
import (
"fmt"
)
func printEngineerName(names []string) {
for index, engineer := range names {
fmt.Printf("Some string at index %v with value %v", index, engineer)
}
@ridhoperdana
ridhoperdana / redundantcode.go
Last active December 30, 2020 05:20
example of write everthing twice
package main
import (
"fmt"
)
func main() {
juniorEngineers := []string{"John", "Doe"}
for index, engineer := range juniorEngineers {
@ridhoperdana
ridhoperdana / betterfunctioname.go
Last active December 30, 2020 05:20
example of function name using verb
package main
import (
"fmt"
)
func printNames() {
names := []string{"John", "Doe"}
for index, name := range names {
@ridhoperdana
ridhoperdana / badfunctionname.go
Last active December 30, 2020 05:21
example of bad function name using noun
package main
import (
"fmt"
)
func names() {
names := []string{"John", "Doe"}
for index, name := range names {
@ridhoperdana
ridhoperdana / goodcode.go
Last active December 30, 2020 05:21
better variable name in a code
package main
import (
"fmt"
)
func main() {
names := []string{"John", "Doe"}
for index, name := range names {
@ridhoperdana
ridhoperdana / badcode.go
Created December 30, 2020 04:23
example of using random variable's name
package main
import (
"fmt"
)
func main() {
l := []string{"John", "Doe"}
for i, v := range l {
@ridhoperdana
ridhoperdana / docker-compose.yml
Last active December 29, 2020 00:57
description of docker compose example
version: '3.7'
networks:
<network_name>:
driver: <network's drive type>
services:
<service_name>:
image: <image_name>:<image_version>
hostname: <hostname>
@ridhoperdana
ridhoperdana / callback_example.dart
Created December 21, 2020 23:06
example of callback function in dart
class Car {
String get type {
return 'Hatchback';
}
}
String carFactory() {
return Car().type;
}
@ridhoperdana
ridhoperdana / async_sync_func.dart
Created December 21, 2020 22:37
example of async and standard function dart
Future<String> asyncFunction(int functionID) async {
return 'This will be run asynchronously $functionID';
}
String standardFunction(int functionID) {
return 'This will be run synchronously $functionID';
}
void startFunction() {
for (int i = 0; i < 10; i++) {
@ridhoperdana
ridhoperdana / state.dart
Created December 21, 2020 12:44
stateless and stateful example stateless and stateful example
class ProfilePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container();
}
}
class LoginPage extends StatefulWidget {
@override
_LoginPageState createState() => _LoginPageState();