Giter VIP home page Giter VIP logo

jmailtm's Introduction

Hi, I'm Shivam ๐Ÿ‘‹

A student from India who likes to program stuff ๐Ÿš€

Languages and Tools :

Java Cplusplus JavaScript Node.js Express Js Arduino

MongoDB Tailwindcss Android Studio Idea Visual Studio Code HTML5

CSS3 React


โšก Discord Status
โšก GitHub Stats
Shivzee's GitHub Stats

Shivzee

jmailtm's People

Contributors

aarahmanqa avatar awidesky avatar shivam1608 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

jmailtm's Issues

Add null checks on all the field retrievals to avoid NullPointerException

Whenever we retrieve a value from the json field, we use .toString() which could throw NullPointerException. That field may be allowed to have null but since we have .toString() we would end up with NPE. This PR aims at avoiding such NPE. Its a better alternative to null check.
PFB the PR raised for the same.
#7

Support synchronous methods

There are some methods which only gives asynchronous option.
Like delete method in JMailTM class, or save method in Attachment class.

For me it looks like a good idea to give a synchronous version of this method.
It doesn't look a hard task to do since these methods have similar format(just some code snippet surrounded by new Thread(new Runnable() { ... }).start();).

So I'll be happy to do some contribution myself, but I'm not sure what is best option to achieve the goal.

1. Just make new synchronous method named like deleteNow

  • code would be like this :
    /**
     * (Synchronous) Deletes the Self Account
     */
    public void deleteNow(){
        try{
                IO.requestDELETE(baseUrl+"/accounts/"+id , bearerToken);
        }catch (Exception e){
                System.out.println("|EXCEPTION IGNORE | "+e);
        }
    }
    /**
     * (Asynchronous) Deletes the Self Account
     */
    public void delete(){
        new Thread(this::deleteNow).start();
    }
  • This would be a easy option, not effecting legacy code.
  • It may cause naming confusion, XX(Asynchronous) <-> XXNow(Synchronous) naming pattern doesn't match existing code like asyncXX(Asynchronous) <-> XX(Synchronous) (see fetchMessages)

2. Follow existing naming pattern

  • code would be like this :
    /**
     * (Synchronous) Deletes the Self Account
     */
    public void delete(){
        try{
                IO.requestDELETE(baseUrl+"/accounts/"+id , bearerToken);
        }catch (Exception e){
                System.out.println("|EXCEPTION IGNORE | "+e);
        }
    }
    /**
     * (Asynchronous) Deletes the Self Account
     */
    public void asyncDelete(){
        new Thread(this::deleteNow).start();
    }
  • There will be no naming confusion to users.
  • This does effect legacy code, making many existing code/project broken.

3. Make delete method returns Future object

  • Make a Thread Pool, and submit all asynchronous tasks(deleting account, saving attachments, fetching mails, etc..) to it.
  • In this case, submit method will return a Future object.
  • So it will be easy to wait for the thread, and WorkCallback class will be easily changed to Future<Boolean>
  • It is likely not to effect legacy code, since only return type of the method is changed. But, some rare case(e.g. method referencing like jmailtmObjectList.stream().foreach(JMailTM::delete)) will result an error.
  • A Thread Pool is used, so we should be careful to avoid bottleneck.(but Thread Pool looks like a better option than making new thread every time calling a method)

What would be the best option?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.