Home » Programming Languages » Page 4

I am currently designing some networking code, and this code
expects the caller of the code to give it a port and hostname to
connect to.



Since I am still in the development phase, I can still change many
aspects of the code and more advantages and disadvantages come in for
the code. However, some aspect of the code has left me still wondering
what kind of number I should pass to the underlying socket creation
code.



I have now to decide what version I should keep,



Version 1:



int port = 80;
ServerSocket socket = new ServerSocket(port);


Advantages:




  • Almost al libraries in java expects integers instead of shorts,
    including the InetSocketAddress.



Disadvantages:




  • Using integers instead of shorts has left its security bugs in the
    past by security systems that don't except the underlying code to skip
    the first 16 bits.



Version 2:



short port = 80;
ServerSocket socket = new ServerSocket(port);


Advantages:




  • It follows the underlying system convention from [C] to use 16 bit
    numbers



Disadvantages:




  • There must be a reason why java uses integers, isn't it?






My Question: Should I design my program to accept a
int or a short

Sure MOV "moves" (copies actually) something, but how ? Does it put
the actual value from the source into the destination or puts some
kind of address.



This question came to me when I saw in Jeff Duntemann introductive
assembly book that he is using interrupt 80h of Linux like this:



mov eax,4    ; Specify sys_write call
mov ebx,1 ; Specify File Descriptor 1: Standard output
mov ecx,Buff ; Pass address of the character to write
mov edx,1 ; Pass number of chars to write
int 80h ; Call sys_write


I've had little practice with TASM before I started reading , but
knew about the instruction LEA.So when I saw:



mov ecx,Buff ; Pass address of the character to write


It blew me away since I used LEA(Load Effective Address) or OFFSET
to put addresses into registers and he is using MOV.



Are both forms correct? He is using NASM, though, so is it because
of the Assembler? I am very confused right now, since I was used to
see that MOV puts the value not an address.

I want to mark such methods in my application code with a comment
that highlights that these methods are expected to get called by the
framework / compiler the application is written for, even if the
application code itself contains no calls to them.



F.ex. the methods called by an Inversion of Control framework, like
the beginRender and afterRender of href="http://tapestry.apache.org/" rel="nofollow">Apache Tapestry;
or the ones of an event-driven language, like the
Form_Load of Visual Basic.



I was tempted to say Event handlers but I'm not sure it's
correct to limit the concept to events; f.ex. in Tapestry a page
rendering triggered by one event (like the click on a link) is
composed of several phases and each phase has its own methods, and
they get called by the framework; these phases occur in a predefined
sequence, so it might be misleading for the reader of my comment if I
call "event" each of them.



Sometimes Callback is suggested but I have the doubt that
that only applies to a function that gets passed to other functions as
an argument.



The only thing the functions / methods I'm talking about have in
common is that they get called by the framework / compiler, regardless
of whether the developer also codes explicit calls to it or not.

A common requirement for licenses is that they must be included
with the software. Should licenses for testing frameworks with this
clause be included if the test code is not something that is being
shipped?



In other words: when a library's license asks to be included, is it
only with software that directly uses that library?

Just curious. The most I have ever had was a for loop within a for
loop, because after reading this from Linus
Torvalds:




Tabs are 8 characters, and thus indentations are also 8
characters.
There are heretic movements that try to make indentations 4 (or even
2!) characters deep, and that is akin to trying to define the value
of
PI to be 3.



Rationale: The whole idea behind indentation is to clearly define
where a block of control starts and ends. Especially when you've
been
looking at your screen for 20 straight hours, you'll find it a lot
easier to see how the indentation works if you have large
indentations.



Now, some people will claim that having 8-character indentations
makes
the code move too far to the right, and makes it hard to read on a
80-character terminal screen. The answer to that is that if
you need
more than 3 levels of indentation, you're screwed anyway, and should
fix your program.




rel="nofollow">https://www.kernel.org/doc/Documentation/CodingStyle



I figured it was an unacceptable practice for me to go to a third
layer of looping, and would restructure my code (Primarily Qt).



Was Linus joking?



Does it depend on the language or application?



Are there some things which absolutely need three or more levels of
looping?

Querying parse for data to populate List view..!
Im unable to display Data in Listview ..!
And There Is No Error In this Project.!



MainActivity



public class MainActivity extends Activity {



ImageView banners;
// Declare Variables
ListView listview;




ArrayList<OnlineProducts> productsList = new
ArrayList<OnlineProducts>();



@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);


listview = (ListView) findViewById(R.id.listview);

Initialization();


ParseQuery<OnlineProducts> query=new
ParseQuery<OnlineProducts>("Product");

query.findInBackground(new FindCallback<OnlineProducts>() {
@Override
public void done(List<OnlineProducts> list,
com.parse.ParseException e) {

if(e!=null)
{
Toast.makeText(getApplicationContext(),"Error
"+e,Toast.LENGTH_SHORT).show();
}

for(OnlineProducts products : list)
{
OnlineProducts Productx=new OnlineProducts();
OnlineProducts OP=new OnlineProducts();
OP.setTitle(products.getTitle());
OP.setPrice(products.getPrice());
productsList.add(OP);//

}


// ArrayAdapter<OnlineProducts> Adptr =new
ArrayAdapter<OnlineProducts>(MainActivity.this,android.R.layout.simple_expandable_list_item_1,productsList);


CustomAdapter adapter = new CustomAdapter(MainActivity.this,
R.layout.viewlist, productsList);



listview.setAdapter(adapter);



}
});


}



CustomAdapter Class
public class CustomAdapter extends ArrayAdapter {



private ArrayList<OnlineProducts> productsList;

private Context mContext;

public CustomAdapter(Context context, int resource,
ArrayList<OnlineProducts> productsList) {

super(context, resource);
mContext = context;

this.productsList= productsList;
}



@Override

public View getView(int position, View convertView, ViewGroup parent)
{

View v = convertView;

OnlineProducts onlineProducts = productsList.get(position);

if(v==null){

LayoutInflater inflater =(LayoutInflater)
getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

v=inflater.inflate(R.layout.viewlist,null);

}


TextView title = (TextView)v.findViewById(R.id.textView2);
TextView price=(TextView)v.findViewById(R.id.textView3);
ImageView imageView=(ImageView)v.findViewById(R.id.imageView2);

if (title != null && price!=null) {

title.setText(onlineProducts.getTitle());
price.setText(onlineProducts.getPrice());
}

return v;

}


}



OnlineProduct
@ParseClassName("Product")
public class OnlineProducts extends ParseObject {



public void setTitle(String title)


{
put("title",title);
}
public String getTitle()
{
return getString("title");
}



public void setPrice(String price)
{
put("Price",price);
}



public String getPrice()
{
return getString("Price");

}


@Override
public String toString() {
return getString("title")+ "/n"+getString("Price");

}


}



ListItems









ListView



<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:id="@+id/imageView"

android:layout_alignParentTop="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="All Brands"
android:id="@+id/textView"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_below="@+id/imageView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textSize="22dp"
android:textColorHighlight="#e11414" />

<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/listview"
android:layout_below="@+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />


I am new to VBA/ Excel and I am trying to convert a Dynamic range
that I have defined into a variable so that I can have a comboBox that
uses the items in the defined range, how do I do it?

When FaceBook or Google give me an API key, are they just storing
it in a database?



Unlike a password, where you can hash and salt it before putting it
in the database, it seems to me that a key needs to be stored as-is
(or else in a reversible form) so that they can provide it to me upon
request.



My concern is with storing immediately usable information in my
databases.



I understand that the exact method these companies use is only
speculation, unless you are a past employee or have unique insider
information, but I'm wondering if there is a most commonly accepted
best-practice.

I like the suggestion in href="https://gist.github.com/bobbygrace/9e961e8982f42eb91b80"
rel="nofollow">Trello CSS guide to separate presentation from
behavior - for instance, I might have a .c-login-button
class for describing what the button looks like, but
.js-login-button for hooking up an event in
JavaScript.



I'm trying to find out the best way to extend this convention to
tests. Both client-side tests (written in Jasmine) and full
integration tests (in Selenium) need to access interface elements, for
example click on the login button. I see the following
possibilities:




  • using the .js- classes in tests - that would,
    however, mean that I add these classes to many elements that are not
    dynamic, such as normal links,


  • using presentation classes in tests - I'm afraid the tests
    would become too easy to break because of that; and the tests are for
    behavior, not presentation,


  • creating another type of classes (.test-,
    .test-login-button) just for tests - but then I'm afraid
    of many elements having multiple classes (such as <button
    class="c-login-button js-login-button test-login-button">
    )
    and the code becoming unreadable because of that.




What would be a good option? Are there any other good possibilities
that I missed?

I have been looking at Microservices for a while now. The concept
is not new but it's communicated in a lightweight manner. So, I am
very excited about this.



However, there is a question that I am not sure what the answer is:
is each microservice supposed to have its own isolated data storage
model completely? Consider the below:




Note: This is probably not a good example as the seperation here
is done based on read/writes whereas the good approach would be to
separate the business concerns.





  • products-write-service: responsible for dealing with creation and
    edits of the products. Knows MongoDB and writes data to there.

  • products-lookup-service: responsible for dealing with retrieving
    products by their identifiers, providing basic listing of products
    based on categories, etc. Knows MongoDB and reads data from
    there.

  • products-search-service: responsible for dealing with search
    requests on products. Knows Elasticsearch and reads data from
    there.



Here, we have two separate data storage techs between three
services. However:




  • products-write-service and
    products-lookup-service works on the same data storage
    model. There is a tried relationship between two services.

  • at the end of the day, there should be a process to do ETL from
    MongoDB to Elasticsearch for products-search-service to
    function. In some sense, three microservices have their own data
    storage model but there is a middle process which knows about these
    two models.



What do you say about this model? Is the separation completely
wrong here?


- Technology - Languages
+ Webmasters
+ Development
+ Development Tools
+ Internet
+ Mobile Programming
+ Linux
+ Unix
+ Apple
+ Ubuntu
+ Mobile & Tablets
+ Databases
+ Android
+ Network & Servers
+ Operating Systems
+ Coding
+ Design Software
+ Web Development
+ Game Development
+ Access
+ Excel
+ Web Design
+ Web Hosting
+ Web Site Reviews
+ Domain Name
+ Information Security
+ Software
+ Computers
+ Electronics
+ Hardware
+ Windows
+ PHP
+ ASP/ASP.Net
+ C/C++/C#
+ VB/VB.Net
+ JAVA
+ Javascript
+ Programming
Privacy Policy - Copyrights Notice - Feedback - Report Violation 2018 © BigHow