# Subclasses

Subclassing is completely optional, however it has many advantages, including terseness, extensibility, and support for autocomplete. In Symbyoz you can **automatically** generate subclasses of your Modules, in `Swift` and `Java` , from the **Configuration** section of your backend.

It will literally transforms this code:

{% tabs %}
{% tab title="Java" %}

```java
ParseObject object = new ParseObject("ClassName");
object.put("displayName", "John Doe");
object.put("isFunny", false);
object.put("age", 50);
```

{% endtab %}

{% tab title="Swift" %}

```swift
var object = PFObject(className:"ClassName")
object["displayName"] = "John Doe"
object["isFunny"] = false
object["age"] = 50
```

{% endtab %}
{% endtabs %}

Into this:

{% tabs %}
{% tab title="Java" %}

```java
ClassName object = new ClassName();
object.setDisplayName("John Doe");
object.setIsFunny(false);
object.setAge(50);
```

{% endtab %}

{% tab title="Swift" %}

```swift
var object = ClassName()
object.displayName = "John Doe"
object.isFunny = false
object.age = 50
```

{% endtab %}
{% endtabs %}

## Creating Subclass

Follow this example to have your own subclass ready to use.

1. Create your class as following

{% tabs %}
{% tab title="Java" %}
{% code title="ClassName.java" %}

```java
import com.parse.ParseClassName;
import com.parse.ParseObject;

@ParseClassName("ClassName")
public class ClassName extends ParseObject
{
  public String getDisplayName() 
  {
    return getString("displayName");
  }
  
  public void setDisplayName(String value) 
  {
    put("displayName", value);
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}

```swift
import Foundation
import Parse

class Address: PFObject, PFSubclassing
{
    @NSManaged var media:  PFFile?
    @NSManaged var fullAddress:  String?
    @NSManaged var street:  String?
    @NSManaged var googlePlaceId:  String?
    @NSManaged var city:  String?
    @NSManaged var streetNumber:  String?
    @NSManaged var isDeleted:  Bool
    @NSManaged var owner:  PFUser?
    @NSManaged var location:  PFGeoPoint?
    @NSManaged var country:  String?
    @NSManaged var postalCode:  String?
    @NSManaged var comment:  String?
    @NSManaged var isBillingAddress:  Bool
        
    override init()
    {
        Address.registerSubclass()
        super.init()
    }
    
    static func parseClassName() -> String
    {
        return "Address"
    }
}
```

{% endtab %}
{% endtabs %}

2\. Register your class before you initialize Parse in your `Application` class

{% tabs %}
{% tab title="Java" %}
{% code title="MyApp.java" %}

```java
import com.parse.Parse;
import android.app.Application;

public class MyApp extends Application 
{
  @Override
  public void onCreate() 
  {
    super.onCreate();
    
    // REGISTER SUBCLASSES HERE
    ParseObject.registerSubclass(ClassName.class);
    
    // Initialize Parse SDK (more info at "Connect to Android App")
    Parse.initialize(new Parse.Configuration.Builder(this)
      .applicationId("YOUR_APP_ID")
      .clientKey("YOUR_CLIENT_KEY")
      .server("https://xxxx.parse-symbyoz.com/parse/")
      .enableLocalDataStore()
      .build()); 
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

And you're all done!&#x20;

Now you can simply use it as you would use any other `Object` but with a structured model and accessor added.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.symbyoz.io/code_examples/subclasses.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
