Skip to content

Instantly share code, notes, and snippets.

@esoxjem
esoxjem / Logging
Last active November 16, 2020 11:16 — forked from kashifrazzaqui/gist:f2c249a1033f4cdb47239dbb6a18889b
Alternatives to logging
Logging is used for 3 primary goals
* debugging
* tracing - understanding execution flow of the program in real life
* checking inputs
There are better tools available for all these three tasks for most usecases
Lets see each case.
Debugging - When a bug is reported the first order of business is to write a test case that fails and this failure clearly indicates that the bug is present - the code is then modified till this test passes (and no other ones fail) - no need for logging
@esoxjem
esoxjem / BitmapFileLoader.java
Created May 6, 2016 10:45 — forked from kashifrazzaqui/BitmapFileLoader.java
Scaling a bitmap in android
import android.graphics.*;
import android.net.Uri;
public class BitmapFileLoader
{
public static Bitmap loadFromUri(Uri fileUri, float maxWidth, float maxHeight)
{
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(fileUri.getPath(), options);
code design guidelines
- when designing libraries its better to leave threads out but not always
- realize that your users may have varying threading strategies and your lib should not prescribe or assert one lest it resists reuse
- typical novice problems
- http://joostdevblog.blogspot.in/2015/01/what-most-young-programmers-need-to.html
- liar variables, methods, classes
- muddy classes
- oversized classes
- code in comments
@esoxjem
esoxjem / superbasic java
Created May 6, 2016 10:25 — forked from kashifrazzaqui/superbasic java
Java basics you MUST know
super basic java
- braces
- define scope
- no masking/shadowing but new variables are welcome
"public void kewl()
{
int x = 7;
{
int x = 8; //Illegal masking
- General
[ ] The code works
[ ] The code is easy to understand
[ ] Follows coding conventions
[ ] Names are simple and if possible short
[ ] Names are spelt correctly
[ ] Names contain units where applicable
[ ] Enums are used instead of int constants where applicable
[ ] There are no usages of 'magic numbers'
[ ] All variables are in the smallest scope possible