Wolfie-Home / webserver2

IFTTT-like web server that connects IoT devices, written in Python Flask and ReactJS
6 stars 1 forks source link

Random Comments and Remarks #11

Open cjackie opened 8 years ago

cjackie commented 8 years ago

@kbumsik

we can put random comments here.

I looked through your implementation of DB in python level. So "service" is directly interacting with SQLite. "model", which is built upon "service", is a higher level abstraction to model an object representing in SQLite.

I feel like It is sort of how ORM was implemented in Python Django Framework. :p

kbumsik commented 8 years ago

I will make an additional layer called DAO as a lower level of Service soon 😛 DAO will be object that directly query to the DB. And Service will use multiple dao to make a single transaction. And model's class methods will request services and map results into model. The internal structures of DB accessing layers shouldn't be very different from each other, except that ORM will have (I think) additional things to build queries intelligently for targeted RDBMS and caching to compensate performance. They access the same RDBMS anyway 😋

cjackie commented 8 years ago

You have nailed down module design. Loll.

cjackie commented 8 years ago

@yiochen

I have question for you. How does UI designers collaborate with engineers? I found it difficult to do. For example, how designers can convey ideas and let other engineers know. Do engineers take part in designing. Is it a good idea? Or the role of engineering and designing is starting to merge?

I reseach about google material design principle. I found designing a very interesting topic!!

kbumsik commented 8 years ago

I found quite interesting blog. It's blog is usually about Python and Python implementation. For example, this post shows Twitter crawler architecture.

More interestingly, I read Python's dictionary implementation in C from this blog. Inspired by this, I am making JSON builder/parser now. Currently JSON string entry insert(), get(), and delete() functions are implemented. I am now making it support integer and floating point. 😛

yiochen commented 8 years ago

@cjackie Um. I think nowadays there is no difference between designer and front end developer. The person in charged of making front end should be able to code and has some sort of design taste.

cjackie commented 8 years ago

@yiochen I see, thanks!! I want to design good pages for our project.

@kbumsik Yes, the blog is interesting. And reading those is definitely going to help with our technical interviews. 😆

kbumsik commented 8 years ago

@cjackie I finally made a basic JSON Builder/Parser using Python dictionary implementation :smiley: . It does not support object and array as values yet but when this library supports them it will be quite good library for general use :)

cjackie commented 8 years ago

@kbumsik

Cool! API looks very clear. Memory management is also clear. I looked briefly on the source code, looks very high quality. It is definitely good piece of code for studying. Are you implement something similar to Python's dictionary implementation in C?

But I'm wondering how do you handle errors though? For example:

things like that.

kbumsik commented 8 years ago

@cjackie

buffer size is too small.

It will return JSON_BUFFER_FULL before any operation is done. Furthermore, json.h also returns JSON_TABLE_FULL when the table is full as well. To workaround, you can use json_replace_buffer or json_double_table.

For your information, using json.h library is assumed that you know how much buffer and how many entries you use, because it does not have dynamic memory allocation.

However, emJSON.h is just wrapper functions to avoid those problems, using dynamic memory allocations. emJSON.c has very short codes. You will easily see how I handle the error messages of json.h libraries in emJSON.c.

use jsonget* but no key associated with it.

Because C does not have exception handling and it is not a recommend things even in C++ in the field of embedded system (because the MCU CPU does not support those kinds of hardware faults nor there is no OS handling exceptions). So I decided to return default values such as:

use json_get_float, but the actual type is a string.

I didn't thought about that. Currently it will pick 4 bytes (size of single precision floating point) of the string and tries to convert it into floating point lol. However, each entries in the table contain type information too. So It won't be hard to handle that kinds of error. I will fix that. I fixed that. Now it will return the same default values mentioned above. Thanks for mentioning this problem :)

kbumsik commented 8 years ago

For the algorithm part, I just copied Pyhon's Algorithm for insertion, hashing, and open addressing, without any modifications. The only obvious difference is, Python doubles the table size when it's 2/3 full. In my implementation it will insert entries until it will fully filled, to squeeze out memory. One thing I am not sure is, deletion opertion of mine will delete one entry and then re-insert the rest of all entries (which is costly.) Sure sure how python handle deletion operations.

kbumsik commented 7 years ago

@cjackie Hey Chaojie, could you tell me your development environment and used in the front-end (such as ECMA/JSX version and compiler)?

cjackie commented 7 years ago

@kbumsik loll. you are going to do some front-end development? I was using babel just for compiling ReactJSX code. Syntax for construct React DOM node is pretty nice and straight forward, that is only reason why I use it.. Now, in introspection, class keyword is also good one to use, for building modular and large system.

I did not check what version of ECMA I was using. I know I was using "the one that the browser can interpret directly"... lollll.

kbumsik commented 7 years ago

@cjackie Not sure but it feels like at least I need to know what is going on there. So one more question. Are the compiled js files(such as location.js) no need to be in our repo, as long as we make sure compile/convert them while running?

cjackie commented 7 years ago

@kbumsik No, compiled js files don't need to be in our repo. As long as you compile them and put them into the right place before running.

kbumsik commented 7 years ago

@cjackie Hello :) Have you ever used this pencil before? I tried it because you starred this project one day and it looks very useful for GUI design.

cjackie commented 7 years ago

@kbumsik Hey Bumsik. No, not yet. This tool might be useful one day for me. With this tool, I was hoping to prototype quickly my concept.