Questions tagged [field]

In computer science a field is a smaller piece of data from a larger collection.

In computer science, data that has several parts can be divided into fields. Relational databases arrange data as sets of database records, also called rows or tuples. Each record consists of several fields, also called attributes; the fields of all records form the columns.

In object-oriented programming, field (also called data member or member variable) is the data encapsulated within a class or object. In the case of a regular field (also called instance variable), for each instance of the object there is an instance variable: for example, an Employee class has a Name field and there is one distinct name per employee. A static field (also called class variable) is one variable, which is shared by all instances.

Source: Field (Computer Science) - Wikipedia article

Related tags:

5904 questions
46
votes
8 answers

How can I get access to a Django Model field verbose name dynamically?

I'd like to have access to one my model field verbose_name. I can get it by the field indice like this model._meta._fields()[2].verbose_name but I need to get it dynamically. Ideally it would be something like this…
philgo20
  • 6,337
  • 6
  • 34
  • 43
45
votes
4 answers

How can I improve performance of Field.set (perhap using MethodHandles)?

I'm writing some code that calls Field.set and Field.get many many thousands of times. Obviously this is very slow because of the reflection. I want to see if I can improve performance using MethodHandle in Java 7. So far here's what I have: Instead…
aloo
  • 5,331
  • 7
  • 55
  • 94
45
votes
4 answers

How to remove a field from the parent Form in a subclass?

class LoginForm(forms.Form): nickname = forms.CharField(max_length=100) username = forms.CharField(max_length=100) password = forms.CharField(widget=forms.PasswordInput) class LoginFormWithoutNickname(LoginForm): # i don't want the…
apelliciari
  • 8,241
  • 9
  • 57
  • 92
44
votes
10 answers

What is the C# static fields naming convention?

I have recently started using ReSharper which is a fantastic tool. Today I came across a naming rule for static fields, namely prefixing with an underscore, i.e. private static string _myString; Is this really the standard way to name static…
Matt
  • 2,730
  • 4
  • 28
  • 35
43
votes
9 answers

Get name of a field

Is it possible in Java to get a name of field in string from the actual field? like: public class mod { @ItemID public static ItemLinkTool linkTool; public void xxx{ String fieldsName = *getFieldsName(linkTool)*; } } PS:…
monnef
  • 3,903
  • 5
  • 30
  • 50
42
votes
5 answers

Use columns from the main query in the subquery

Is there any way to get a column in real time, from a main query, and use it in a subquery? Something like this: (Use A.item in the subquery) SELECT item1, * FROM TableA A INNER JOIN ( select * from TableB B where A.item = B.item )…
João Guilherme
  • 503
  • 1
  • 5
  • 8
42
votes
10 answers

PHP: check if any posted vars are empty - form: all fields required

Is there a simpler function to something like this: if (isset($_POST['Submit'])) { if ($_POST['login'] == "" || $_POST['password'] == "" || $_POST['confirm'] == "" || $_POST['name'] == "" || $_POST['phone'] == "" || $_POST['email'] == "") { …
FFish
  • 10,964
  • 34
  • 95
  • 136
42
votes
12 answers

Properties vs. Fields: Need help grasping the uses of Properties over Fields

First off, I have read through a list of postings on this topic and I don't feel I have grasped properties because of what I had come to understand about encapsulation and field modifiers (private, public..ect). One of the main aspects of C# that I…
pghtech
  • 3,642
  • 11
  • 48
  • 73
42
votes
3 answers

Add code to C# get/set of property without needing backing field?

You know how you can have a property that automatically generates a backing field? Like if I go: public String SomeProperty {get; set;} I know that if I want to add code to that property I have to create the backing field as so: public string…
ashley
  • 521
  • 1
  • 5
  • 6
41
votes
3 answers

Printing only the first field in a string

I have a date as 12/12/2013 14:32 I want to convert it into only 12/12/2013. The string can be 1/1/2013 12:32 or 1/10/2013 23:41 I need only the date part.
user2099444
  • 421
  • 1
  • 4
  • 3
40
votes
4 answers

Java: Adding fields and methods to existing Class?

Is there, in Java, a way to add some fields and methods to an existing class? What I want is that I have a class imported to my code, and I need to add some fields, derived from the existing fields, and their returning methods. Is there any way to…
Pots Spi
  • 591
  • 1
  • 4
  • 4
38
votes
4 answers

Number of fields returned by awk

Is there a way to get awk to return the number of fields that meet a field-separator criteria? Say, for instance, the file contains: a b c d So, awk -F=' ' | should return 4.
Sriram
  • 10,298
  • 21
  • 83
  • 136
37
votes
4 answers

Django: Admin: changing the widget of the field in Admin

I have a model with a boolean value like that: class TagCat(models.Model): by_admin = models.BooleanField(default=True) This appears as a checkbox in admin. How could I use this as a radio button in admin? Also, how do I make it be always…
mgPePe
  • 5,677
  • 12
  • 52
  • 85
36
votes
5 answers

Loop over all fields in a Java class

I have a Java class that has a number of Fields. I would like to Loop over al lthe fields and do something for the one's that are null. For example if my class is: public class ClassWithStuff { public int inty; public stringy; …
CodyBugstein
  • 21,984
  • 61
  • 207
  • 363
35
votes
2 answers

How to get fields of a Julia object

Given a Julia object of composite type, how can one determine its fields? I know one solution if you're working in the REPL: First you figure out the type of the object via a call to typeof, then enter help mode (?), and then look up the type. Is…
Yly
  • 2,150
  • 4
  • 20
  • 33